refactor VectorTileMap

This commit is contained in:
Hannes Janetzek 2012-06-19 04:45:43 +02:00
parent 40cadbe805
commit e7c5831302
45 changed files with 178 additions and 161 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.sfb.tilemap"
package="org.mapsforge.tilemap"
android:installLocation="auto"
android:versionCode="10"
android:versionName="0.1" >
@ -17,15 +17,15 @@
<application
android:icon="@drawable/globe"
android:label="@string/application_name" >
<activity android:name="de.sfb.tilemap.TileMap" >
<activity android:name="org.mapsforge.tilemap.TileMap" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="de.sfb.tilemap.preferences.EditPreferences" />
<activity android:name=".filepicker.FilePicker" />
<activity android:name="org.mapsforge.tilemap.preferences.EditPreferences" />
<activity android:name="org.mapsforge.tilemap.filepicker.FilePicker" />
</application>
</manifest>

View File

@ -1,5 +1,5 @@
/** Automatically generated file. DO NOT MODIFY */
package de.sfb.tilemap;
package org.mapsforge.tilemap;
public final class BuildConfig {
public final static boolean DEBUG = true;

View File

@ -5,7 +5,7 @@
* should not be modified by hand.
*/
package de.sfb.tilemap;
package org.mapsforge.tilemap;
public final class R {
public static final class array {

View File

@ -17,9 +17,7 @@ package org.mapsforge.android;
import java.io.File;
import java.io.FileNotFoundException;
import org.mapsforge.android.inputhandling.MapMover;
import org.mapsforge.android.inputhandling.TouchHandler;
import org.mapsforge.android.inputhandling.ZoomAnimator;
import org.mapsforge.android.mapgenerator.JobParameters;
import org.mapsforge.android.mapgenerator.JobQueue;
import org.mapsforge.android.mapgenerator.JobTheme;
@ -33,15 +31,14 @@ import org.mapsforge.android.rendertheme.InternalRenderTheme;
import org.mapsforge.android.utils.GlConfigChooser;
import org.mapsforge.core.GeoPoint;
import org.mapsforge.core.MapPosition;
import org.mapsforge.mapdatabase.FileOpenResult;
import org.mapsforge.mapdatabase.IMapDatabase;
import org.mapsforge.mapdatabase.mapfile.MapDatabase;
import org.mapsforge.database.FileOpenResult;
import org.mapsforge.database.IMapDatabase;
import org.mapsforge.database.mapfile.MapDatabase;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.MotionEvent;
/**
@ -70,14 +67,15 @@ public class MapView extends GLSurfaceView {
private static final float DEFAULT_TEXT_SCALE = 1;
private final MapController mMapController;
private final MapMover mMapMover;
// private final MapMover mMapMover;
// private final ZoomAnimator mZoomAnimator;
private final MapScaleBar mMapScaleBar;
private final MapViewPosition mMapViewPosition;
private final MapZoomControls mMapZoomControls;
private final Projection mProjection;
private final TouchHandler mTouchEventHandler;
private final ZoomAnimator mZoomAnimator;
private IMapDatabase mMapDatabase;
private MapGenerator mMapGenerator;
@ -151,10 +149,10 @@ public class MapView extends GLSurfaceView {
mJobQueue = new JobQueue(this);
mMapWorker = new MapWorker(this);
mMapWorker.start();
mMapMover = new MapMover(this);
mMapMover.start();
mZoomAnimator = new ZoomAnimator(this);
mZoomAnimator.start();
// mMapMover = new MapMover(this);
// mMapMover.start();
// mZoomAnimator = new ZoomAnimator(this);
// mZoomAnimator.start();
setMapGeneratorInternal(mapGenerator);
@ -232,12 +230,12 @@ public class MapView extends GLSurfaceView {
return mMapGenerator;
}
/**
* @return the MapMover which is used by this MapView.
*/
public MapMover getMapMover() {
return mMapMover;
}
// /**
// * @return the MapMover which is used by this MapView.
// */
// public MapMover getMapMover() {
// return mMapMover;
// }
/**
* @return the current position and zoom level of this MapView.
@ -267,32 +265,32 @@ public class MapView extends GLSurfaceView {
return mProjection;
}
/**
* @return true if the ZoomAnimator is currently running, false otherwise.
*/
public boolean isZoomAnimatorRunning() {
return mZoomAnimator.isExecuting();
}
// /**
// * @return true if the ZoomAnimator is currently running, false otherwise.
// */
// public boolean isZoomAnimatorRunning() {
// return mZoomAnimator.isExecuting();
// }
@Override
public boolean onKeyDown(int keyCode, KeyEvent keyEvent) {
return mMapMover.onKeyDown(keyCode, keyEvent);
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent keyEvent) {
return mMapMover.onKeyUp(keyCode, keyEvent);
}
// @Override
// public boolean onKeyDown(int keyCode, KeyEvent keyEvent) {
// return mMapMover.onKeyDown(keyCode, keyEvent);
// }
//
// @Override
// public boolean onKeyUp(int keyCode, KeyEvent keyEvent) {
// return mMapMover.onKeyUp(keyCode, keyEvent);
// }
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
return mTouchEventHandler.handleMotionEvent(motionEvent);
}
@Override
public boolean onTrackballEvent(MotionEvent motionEvent) {
return mMapMover.onTrackballEvent(motionEvent);
}
// @Override
// public boolean onTrackballEvent(MotionEvent motionEvent) {
// return mMapMover.onTrackballEvent(motionEvent);
// }
/**
* Calculates all necessary tiles and adds jobs accordingly.
@ -365,17 +363,16 @@ public class MapView extends GLSurfaceView {
return false;
}
mZoomAnimator.pause();
// mZoomAnimator.pause();
// mMapMover.pause();
mMapWorker.pause();
mMapMover.pause();
mZoomAnimator.awaitPausing();
mMapMover.awaitPausing();
// mZoomAnimator.awaitPausing();
// mMapMover.awaitPausing();
mMapWorker.awaitPausing();
mMapMover.stopMove();
mZoomAnimator.proceed();
// mZoomAnimator.proceed();
// mMapMover.stopMove();
// mMapMover.proceed();
mMapWorker.proceed();
mMapMover.proceed();
mMapDatabase.closeFile();
FileOpenResult fileOpenResult = mMapDatabase.openFile(new File(mapFile));
@ -588,9 +585,9 @@ public class MapView extends GLSurfaceView {
}
void destroy() {
mMapMover.interrupt();
// mMapMover.interrupt();
mMapWorker.interrupt();
mZoomAnimator.interrupt();
// mZoomAnimator.interrupt();
try {
mMapWorker.join();
@ -617,10 +614,9 @@ public class MapView extends GLSurfaceView {
boolean hasValidCenter() {
if (!mMapViewPosition.isValid()) {
return false;
} else if (!mMapGenerator.requiresInternetConnection() &&
(!mMapDatabase.hasOpenFile() ||
!mMapDatabase.getMapFileInfo().boundingBox
.contains(getMapPosition().getMapCenter()))) {
} else if (!mMapGenerator.requiresInternetConnection()
&& (!mMapDatabase.hasOpenFile() || !mMapDatabase.getMapFileInfo().boundingBox.contains(getMapPosition()
.getMapCenter()))) {
return false;
}
@ -635,16 +631,16 @@ public class MapView extends GLSurfaceView {
public void onPause() {
super.onPause();
mMapWorker.pause();
mMapMover.pause();
mZoomAnimator.pause();
// mMapMover.pause();
// mZoomAnimator.pause();
}
@Override
public void onResume() {
super.onResume();
mMapWorker.proceed();
mMapMover.proceed();
mZoomAnimator.proceed();
// mMapMover.proceed();
// mZoomAnimator.proceed();
}
/**

View File

@ -33,9 +33,9 @@ import org.mapsforge.core.GeoPoint;
import org.mapsforge.core.SphericalMercator;
import org.mapsforge.core.Tag;
import org.mapsforge.core.Tile;
import org.mapsforge.mapdatabase.IMapDatabase;
import org.mapsforge.mapdatabase.IMapDatabaseCallback;
import org.mapsforge.mapdatabase.MapFileInfo;
import org.mapsforge.database.IMapDatabase;
import org.mapsforge.database.IMapDatabaseCallback;
import org.mapsforge.database.MapFileInfo;
import org.xml.sax.SAXException;
import android.graphics.Bitmap;

View File

@ -14,7 +14,7 @@
*/
package org.mapsforge.android.mapgenerator;
import org.mapsforge.mapdatabase.IMapDatabase;
import org.mapsforge.database.IMapDatabase;
import android.util.AttributeSet;
@ -33,7 +33,7 @@ public final class MapDatabaseFactory {
public static IMapDatabase createMapDatabase(AttributeSet attributeSet) {
String mapDatabaseName = attributeSet.getAttributeValue(null, MAP_DATABASE_ATTRIBUTE_NAME);
if (mapDatabaseName == null) {
return new org.mapsforge.mapdatabase.mapfile.MapDatabase();
return new org.mapsforge.database.mapfile.MapDatabase();
}
MapDatabaseInternal mapDatabaseInternal = MapDatabaseInternal.valueOf(mapDatabaseName);
@ -48,11 +48,11 @@ public final class MapDatabaseFactory {
public static IMapDatabase createMapDatabase(MapDatabaseInternal mapDatabaseInternal) {
switch (mapDatabaseInternal) {
case MAP_READER:
return new org.mapsforge.mapdatabase.mapfile.MapDatabase();
return new org.mapsforge.database.mapfile.MapDatabase();
case JSON_READER:
return new org.mapsforge.mapdatabase.json.MapDatabase();
return new org.mapsforge.database.json.MapDatabase();
case POSTGIS_READER:
return new org.mapsforge.mapdatabase.postgis.MapDatabase();
return new org.mapsforge.database.postgis.MapDatabase();
}

View File

@ -17,7 +17,7 @@ package org.mapsforge.android.mapgenerator;
import org.mapsforge.android.MapRenderer;
import org.mapsforge.android.MapView;
import org.mapsforge.core.GeoPoint;
import org.mapsforge.mapdatabase.IMapDatabase;
import org.mapsforge.database.IMapDatabase;
/**
* A MapGenerator provides map tiles either by downloading or rendering them.

View File

@ -385,7 +385,7 @@
stroke-linecap="butt" />
</rule>
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-min="16">
<line stroke="#c1bcb6" stroke-width="0.25" stroke-linecap="butt" />
<line stroke="#c1bcb6" stroke-width="0.2" stroke-linecap="butt" />
</rule>
</rule>

View File

@ -33,10 +33,10 @@ import org.mapsforge.android.rendertheme.renderinstruction.Line;
import org.mapsforge.core.GeoPoint;
import org.mapsforge.core.Tag;
import org.mapsforge.core.Tile;
import org.mapsforge.mapdatabase.IMapDatabase;
import org.mapsforge.mapdatabase.IMapDatabaseCallback;
import org.mapsforge.mapdatabase.MapFileInfo;
import org.mapsforge.mapdatabase.mapfile.MapDatabase;
import org.mapsforge.database.IMapDatabase;
import org.mapsforge.database.IMapDatabaseCallback;
import org.mapsforge.database.MapFileInfo;
import org.mapsforge.database.mapfile.MapDatabase;
import org.xml.sax.SAXException;
import android.graphics.Bitmap;

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase;
package org.mapsforge.database;
/**

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase;
package org.mapsforge.database;
import java.io.File;

View File

@ -12,10 +12,10 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase;
package org.mapsforge.database;
import org.mapsforge.core.Tag;
import org.mapsforge.mapdatabase.mapfile.MapDatabase;
import org.mapsforge.database.mapfile.MapDatabase;
/**
* Callback methods which can be triggered from the {@link MapDatabase}.

View File

@ -12,11 +12,11 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase;
package org.mapsforge.database;
import org.mapsforge.core.BoundingBox;
import org.mapsforge.core.GeoPoint;
import org.mapsforge.mapdatabase.mapfile.MapDatabase;
import org.mapsforge.database.mapfile.MapDatabase;
/**
* Contains the immutable metadata of a map file.

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.json;
package org.mapsforge.database.json;
import java.io.File;
@ -20,10 +20,10 @@ import org.mapsforge.core.BoundingBox;
import org.mapsforge.core.MercatorProjection;
import org.mapsforge.core.Tag;
import org.mapsforge.core.Tile;
import org.mapsforge.mapdatabase.FileOpenResult;
import org.mapsforge.mapdatabase.IMapDatabase;
import org.mapsforge.mapdatabase.IMapDatabaseCallback;
import org.mapsforge.mapdatabase.MapFileInfo;
import org.mapsforge.database.FileOpenResult;
import org.mapsforge.database.IMapDatabase;
import org.mapsforge.database.IMapDatabaseCallback;
import org.mapsforge.database.MapFileInfo;
/**
*

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.mapfile;
package org.mapsforge.database.mapfile;
/**
* This utility class contains methods to convert byte arrays to numbers.

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.mapfile;
package org.mapsforge.database.mapfile;
import java.io.IOException;
import java.io.RandomAccessFile;
@ -21,7 +21,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.mapsforge.core.LRUCache;
import org.mapsforge.mapdatabase.mapfile.header.SubFileParameter;
import org.mapsforge.database.mapfile.header.SubFileParameter;
/**
* A cache for database index blocks with a fixed size and LRU policy.

View File

@ -12,9 +12,9 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.mapfile;
package org.mapsforge.database.mapfile;
import org.mapsforge.mapdatabase.mapfile.header.SubFileParameter;
import org.mapsforge.database.mapfile.header.SubFileParameter;
/**
* An immutable container class which is the key for the index cache.

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.mapfile;
package org.mapsforge.database.mapfile;
import java.io.File;
import java.io.IOException;
@ -23,12 +23,12 @@ import java.util.logging.Logger;
import org.mapsforge.core.MercatorProjection;
import org.mapsforge.core.Tag;
import org.mapsforge.core.Tile;
import org.mapsforge.mapdatabase.FileOpenResult;
import org.mapsforge.mapdatabase.IMapDatabase;
import org.mapsforge.mapdatabase.IMapDatabaseCallback;
import org.mapsforge.mapdatabase.mapfile.header.MapFileHeader;
import org.mapsforge.mapdatabase.mapfile.header.MapFileInfo;
import org.mapsforge.mapdatabase.mapfile.header.SubFileParameter;
import org.mapsforge.database.FileOpenResult;
import org.mapsforge.database.IMapDatabase;
import org.mapsforge.database.IMapDatabaseCallback;
import org.mapsforge.database.mapfile.header.MapFileHeader;
import org.mapsforge.database.mapfile.header.MapFileInfo;
import org.mapsforge.database.mapfile.header.SubFileParameter;
/**
* A class for reading binary map files.
@ -227,6 +227,9 @@ public class MapDatabase implements IMapDatabase {
*/
@Override
public void executeQuery(Tile tile, IMapDatabaseCallback mapDatabaseCallback) {
if (mMapFileHeader == null)
return;
if (mIntBuffer == null)
mIntBuffer = new int[MAXIMUM_WAY_NODES_SEQUENCE_LENGTH * 2];

View File

@ -12,10 +12,10 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.mapfile;
package org.mapsforge.database.mapfile;
import org.mapsforge.core.Tile;
import org.mapsforge.mapdatabase.mapfile.header.SubFileParameter;
import org.mapsforge.database.mapfile.header.SubFileParameter;
final class QueryCalculations {
private static int getFirstLevelTileBitmask(Tile tile) {

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.mapfile;
package org.mapsforge.database.mapfile;
class QueryParameters {
long fromBaseTileX;

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.mapfile;
package org.mapsforge.database.mapfile;
import java.io.IOException;
import java.io.RandomAccessFile;

View File

@ -12,12 +12,12 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.mapfile.header;
package org.mapsforge.database.mapfile.header;
import java.io.IOException;
import org.mapsforge.mapdatabase.FileOpenResult;
import org.mapsforge.mapdatabase.mapfile.ReadBuffer;
import org.mapsforge.database.FileOpenResult;
import org.mapsforge.database.mapfile.ReadBuffer;
/**
* Reads and validates the header data from a binary map file.

View File

@ -12,17 +12,17 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.mapfile.header;
package org.mapsforge.database.mapfile.header;
import org.mapsforge.core.Tag;
import org.mapsforge.mapdatabase.mapfile.MapDatabase;
import org.mapsforge.database.mapfile.MapDatabase;
/**
* Contains the immutable metadata of a map file.
*
* @see MapDatabase#getMapFileInfo()
*/
public class MapFileInfo extends org.mapsforge.mapdatabase.MapFileInfo {
public class MapFileInfo extends org.mapsforge.database.MapFileInfo {
/**
* True if the map file includes debug information, false otherwise.

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.mapfile.header;
package org.mapsforge.database.mapfile.header;
import org.mapsforge.core.BoundingBox;
import org.mapsforge.core.Tag;

View File

@ -12,11 +12,11 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.mapfile.header;
package org.mapsforge.database.mapfile.header;
import org.mapsforge.core.GeoPoint;
import org.mapsforge.mapdatabase.FileOpenResult;
import org.mapsforge.mapdatabase.mapfile.ReadBuffer;
import org.mapsforge.database.FileOpenResult;
import org.mapsforge.database.mapfile.ReadBuffer;
final class OptionalFields {
/**

View File

@ -12,14 +12,14 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.mapfile.header;
package org.mapsforge.database.mapfile.header;
import java.io.IOException;
import org.mapsforge.core.BoundingBox;
import org.mapsforge.core.Tag;
import org.mapsforge.mapdatabase.FileOpenResult;
import org.mapsforge.mapdatabase.mapfile.ReadBuffer;
import org.mapsforge.database.FileOpenResult;
import org.mapsforge.database.mapfile.ReadBuffer;
final class RequiredFields {
/**

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.mapfile.header;
package org.mapsforge.database.mapfile.header;
import org.mapsforge.core.MercatorProjection;

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.mapfile.header;
package org.mapsforge.database.mapfile.header;
import org.mapsforge.core.BoundingBox;

View File

@ -24,7 +24,7 @@
* $Id: Geometry.java 9324 2012-02-27 22:08:12Z pramsey $
*/
package org.mapsforge.mapdatabase.postgis;
package org.mapsforge.database.postgis;
import java.io.Serializable;

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.mapdatabase.postgis;
package org.mapsforge.database.postgis;
import java.io.File;
import java.sql.Connection;
@ -29,10 +29,10 @@ import org.mapsforge.core.GeoPoint;
import org.mapsforge.core.SphericalMercator;
import org.mapsforge.core.Tag;
import org.mapsforge.core.Tile;
import org.mapsforge.mapdatabase.FileOpenResult;
import org.mapsforge.mapdatabase.IMapDatabase;
import org.mapsforge.mapdatabase.IMapDatabaseCallback;
import org.mapsforge.mapdatabase.MapFileInfo;
import org.mapsforge.database.FileOpenResult;
import org.mapsforge.database.IMapDatabase;
import org.mapsforge.database.IMapDatabaseCallback;
import org.mapsforge.database.MapFileInfo;
import org.postgresql.PGConnection;
/**

View File

@ -19,7 +19,7 @@
*
*-------------------------------------------------------------------------
*/
package org.mapsforge.mapdatabase.postgis;
package org.mapsforge.database.postgis;
import java.sql.SQLException;
import java.util.ArrayList;

View File

@ -22,7 +22,7 @@
* $Id: ValueGetter.java 9324 2012-02-27 22:08:12Z pramsey $
*/
package org.mapsforge.mapdatabase.postgis;
package org.mapsforge.database.postgis;
abstract class ValueGetter {
byte[] data;

View File

@ -12,12 +12,12 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.sfb.tilemap;
package org.mapsforge.tilemap;
import java.text.DecimalFormat;
import android.content.res.Resources;
import de.sfb.tilemap.R;
import org.mapsforge.tilemap.R;
final class FileUtils {
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.00 ");

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.sfb.tilemap;
package org.mapsforge.tilemap;
import android.app.Activity;
import android.os.Bundle;

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.sfb.tilemap;
package org.mapsforge.tilemap;
import org.mapsforge.core.GeoPoint;

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.sfb.tilemap;
package org.mapsforge.tilemap;
import android.widget.SeekBar;
import android.widget.TextView;

View File

@ -1,4 +1,4 @@
package de.sfb.tilemap;
package org.mapsforge.tilemap;
import java.io.FileFilter;
import java.io.FileNotFoundException;
@ -17,8 +17,13 @@ import org.mapsforge.android.rendertheme.InternalRenderTheme;
import org.mapsforge.android.utils.AndroidUtils;
import org.mapsforge.core.BoundingBox;
import org.mapsforge.core.GeoPoint;
import org.mapsforge.mapdatabase.IMapDatabase;
import org.mapsforge.mapdatabase.MapFileInfo;
import org.mapsforge.database.IMapDatabase;
import org.mapsforge.database.MapFileInfo;
import org.mapsforge.tilemap.filefilter.FilterByFileExtension;
import org.mapsforge.tilemap.filefilter.ValidMapFile;
import org.mapsforge.tilemap.filefilter.ValidRenderTheme;
import org.mapsforge.tilemap.filepicker.FilePicker;
import org.mapsforge.tilemap.preferences.EditPreferences;
import android.app.AlertDialog;
import android.app.Dialog;
@ -46,12 +51,6 @@ import android.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import de.sfb.tilemap.R;
import de.sfb.tilemap.filefilter.FilterByFileExtension;
import de.sfb.tilemap.filefilter.ValidMapFile;
import de.sfb.tilemap.filefilter.ValidRenderTheme;
import de.sfb.tilemap.filepicker.FilePicker;
import de.sfb.tilemap.preferences.EditPreferences;
/**
* A map application which uses the features from the mapsforge map library. The map can be centered to the current
@ -78,10 +77,12 @@ public class TileMap extends MapActivity {
private WakeLock wakeLock;
MapController mapController;
MapView mapView;
private Menu mMenu = null;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.options_menu, menu);
mMenu = menu;
return true;
}
@ -99,11 +100,21 @@ public class TileMap extends MapActivity {
return true;
case R.id.menu_position_my_location_enable:
enableShowMyLocation(true);
if (enableShowMyLocation(true)) {
mMenu.findItem(R.id.menu_position_my_location_enable).setVisible(false);
mMenu.findItem(R.id.menu_position_my_location_enable).setEnabled(false);
mMenu.findItem(R.id.menu_position_my_location_disable).setVisible(true);
mMenu.findItem(R.id.menu_position_my_location_disable).setEnabled(true);
}
return true;
case R.id.menu_position_my_location_disable:
disableShowMyLocation();
if (disableShowMyLocation()) {
mMenu.findItem(R.id.menu_position_my_location_enable).setVisible(true);
mMenu.findItem(R.id.menu_position_my_location_enable).setEnabled(true);
mMenu.findItem(R.id.menu_position_my_location_disable).setVisible(false);
mMenu.findItem(R.id.menu_position_my_location_disable).setEnabled(false);
}
return true;
case R.id.menu_position_last_known:
@ -202,21 +213,23 @@ public class TileMap extends MapActivity {
this.mapController = this.mapView.getController();
}
private void enableShowMyLocation(boolean centerAtFirstFix) {
private boolean enableShowMyLocation(boolean centerAtFirstFix) {
if (!this.showMyLocation) {
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
String bestProvider = this.locationManager.getBestProvider(criteria, true);
if (bestProvider == null) {
showDialog(DIALOG_LOCATION_PROVIDER_DISABLED);
return;
return false;
}
this.showMyLocation = true;
this.myLocationListener.setCenterAtFirstFix(centerAtFirstFix);
this.locationManager.requestLocationUpdates(bestProvider, 1000, 0, this.myLocationListener);
this.snapToLocationView.setVisibility(View.VISIBLE);
return true;
}
return false;
}
private void gotoLastKnownPosition() {
@ -527,8 +540,10 @@ public class TileMap extends MapActivity {
/**
* Disables the "show my location" mode.
*
* @return ...
*/
void disableShowMyLocation() {
private boolean disableShowMyLocation() {
if (this.showMyLocation) {
this.showMyLocation = false;
disableSnapToLocation(false);
@ -540,7 +555,9 @@ public class TileMap extends MapActivity {
// this.itemizedOverlay = null;
// }
this.snapToLocationView.setVisibility(View.GONE);
return true;
}
return false;
}
/**

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.sfb.tilemap.filefilter;
package org.mapsforge.tilemap.filefilter;
import java.io.File;
import java.io.FileFilter;

View File

@ -12,11 +12,11 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.sfb.tilemap.filefilter;
package org.mapsforge.tilemap.filefilter;
import java.io.FileFilter;
import org.mapsforge.mapdatabase.FileOpenResult;
import org.mapsforge.database.FileOpenResult;
/**
* An extension of the {@link FileFilter} interface.

View File

@ -12,13 +12,13 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.sfb.tilemap.filefilter;
package org.mapsforge.tilemap.filefilter;
import java.io.File;
import org.mapsforge.mapdatabase.FileOpenResult;
import org.mapsforge.mapdatabase.IMapDatabase;
import org.mapsforge.mapdatabase.mapfile.MapDatabase;
import org.mapsforge.database.FileOpenResult;
import org.mapsforge.database.IMapDatabase;
import org.mapsforge.database.mapfile.MapDatabase;
/**
* Accepts all valid map files.

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.sfb.tilemap.filefilter;
package org.mapsforge.tilemap.filefilter;
import java.io.File;
import java.io.FileInputStream;
@ -23,7 +23,7 @@ import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
import org.mapsforge.android.rendertheme.RenderThemeHandler;
import org.mapsforge.mapdatabase.FileOpenResult;
import org.mapsforge.database.FileOpenResult;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;

View File

@ -12,13 +12,15 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.sfb.tilemap.filepicker;
package org.mapsforge.tilemap.filepicker;
import java.io.File;
import java.io.FileFilter;
import java.util.Arrays;
import java.util.Comparator;
import org.mapsforge.tilemap.filefilter.ValidFileFilter;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
@ -31,8 +33,7 @@ import android.view.View;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.GridView;
import de.sfb.tilemap.R;
import de.sfb.tilemap.filefilter.ValidFileFilter;
import org.mapsforge.tilemap.R;
/**
* A FilePicker displays the contents of directories. The user can navigate within the file system and select a single

View File

@ -12,11 +12,11 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.sfb.tilemap.filepicker;
package org.mapsforge.tilemap.filepicker;
import java.io.File;
import de.sfb.tilemap.R;
import org.mapsforge.tilemap.R;
import android.content.Context;
import android.view.Gravity;

View File

@ -12,13 +12,13 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.sfb.tilemap.preferences;
package org.mapsforge.tilemap.preferences;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.view.WindowManager;
import de.sfb.tilemap.R;
import org.mapsforge.tilemap.R;
/**
* Activity to edit the application preferences.

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package de.sfb.tilemap.preferences;
package org.mapsforge.tilemap.preferences;
import android.content.Context;
import android.content.DialogInterface;