This commit is contained in:
Hannes Janetzek 2012-07-23 17:09:27 +02:00
parent c5ace62b61
commit c5c952bf14
57 changed files with 361 additions and 488 deletions

View File

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

View File

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

View File

@ -1,191 +0,0 @@
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package org.mapsforge.tilemap;
public final class R {
public static final class array {
public static final int preferences_map_database_keys=0x7f050000;
public static final int preferences_map_generator_values=0x7f050004;
public static final int preferences_scale_bar_unit_keys=0x7f050001;
public static final int preferences_scale_bar_unit_values=0x7f050005;
public static final int preferences_text_scale_keys=0x7f050002;
public static final int preferences_text_scale_values=0x7f050006;
public static final int view_sections=0x7f050003;
}
public static final class attr {
}
public static final class drawable {
public static final int action_bar=0x7f020000;
public static final int bar_globe=0x7f020001;
public static final int bar_globe2=0x7f020002;
public static final int btn_snap_normal=0x7f020003;
public static final int btn_snap_pressed=0x7f020004;
public static final int btn_snap_selected=0x7f020005;
public static final int file_picker_back=0x7f020006;
public static final int file_picker_file=0x7f020007;
public static final int file_picker_folder=0x7f020008;
public static final int globe=0x7f020009;
public static final int globe2=0x7f02000a;
public static final int ic_menu_archive=0x7f02000b;
public static final int ic_menu_camera=0x7f02000c;
public static final int ic_menu_info_details=0x7f02000d;
public static final int ic_menu_mapmode=0x7f02000e;
public static final int ic_menu_mylocation=0x7f02000f;
public static final int ic_menu_options=0x7f020010;
public static final int ic_menu_preferences=0x7f020011;
public static final int my_location=0x7f020012;
public static final int snap_to_position=0x7f020013;
}
public static final class id {
public static final int filePickerView=0x7f090003;
public static final int infoMapFileViewArea=0x7f09000d;
public static final int infoMapFileViewComment=0x7f090011;
public static final int infoMapFileViewCreatedBy=0x7f090012;
public static final int infoMapFileViewDate=0x7f09000c;
public static final int infoMapFileViewDebug=0x7f09000b;
public static final int infoMapFileViewLanguagePreference=0x7f090010;
public static final int infoMapFileViewName=0x7f090008;
public static final int infoMapFileViewSize=0x7f090009;
public static final int infoMapFileViewStartPosition=0x7f09000e;
public static final int infoMapFileViewStartZoomLevel=0x7f09000f;
public static final int infoMapFileViewVersion=0x7f09000a;
public static final int latitude=0x7f090004;
public static final int longitude=0x7f090005;
public static final int mainView=0x7f090000;
public static final int mapView=0x7f090001;
public static final int menu_mapfile=0x7f09001e;
public static final int menu_options=0x7f090019;
public static final int menu_position=0x7f090013;
public static final int menu_position_enter_coordinates=0x7f090017;
public static final int menu_position_last_known=0x7f090016;
public static final int menu_position_map_center=0x7f090018;
public static final int menu_position_my_location_disable=0x7f090015;
public static final int menu_position_my_location_enable=0x7f090014;
public static final int menu_preferences=0x7f09001a;
public static final int menu_render_theme=0x7f09001b;
public static final int menu_render_theme_osmarender=0x7f09001c;
public static final int menu_render_theme_select_file=0x7f09001d;
public static final int snapToLocationView=0x7f090002;
public static final int zoomLevel=0x7f090006;
public static final int zoomlevelValue=0x7f090007;
}
public static final class layout {
public static final int activity_advanced_map_viewer=0x7f030000;
public static final int activity_file_picker=0x7f030001;
public static final int dialog_enter_coordinates=0x7f030002;
public static final int dialog_info_map_file=0x7f030003;
}
public static final class menu {
public static final int options_menu=0x7f080000;
}
public static final class string {
public static final int application_name=0x7f060003;
public static final int cancel=0x7f060004;
public static final int error=0x7f060005;
public static final int error_last_location_unknown=0x7f060006;
public static final int file_invalid=0x7f060007;
public static final int file_select=0x7f060008;
public static final int file_size_byte=0x7f060009;
public static final int file_size_bytes=0x7f06000a;
public static final int file_size_gb=0x7f06000d;
public static final int file_size_kb=0x7f06000b;
public static final int file_size_mb=0x7f06000c;
public static final int go_to_position=0x7f06000e;
public static final int info_map_file_area=0x7f06000f;
public static final int info_map_file_comment=0x7f060010;
public static final int info_map_file_created_by=0x7f060011;
public static final int info_map_file_date=0x7f060012;
public static final int info_map_file_debug=0x7f060013;
public static final int info_map_file_debug_no=0x7f060014;
public static final int info_map_file_debug_yes=0x7f060015;
public static final int info_map_file_language_preference=0x7f060016;
public static final int info_map_file_name=0x7f060017;
public static final int info_map_file_size=0x7f060018;
public static final int info_map_file_start=0x7f060056;
public static final int info_map_file_start_position=0x7f060019;
public static final int info_map_file_start_zoom_level=0x7f06001a;
public static final int info_map_file_version=0x7f06001b;
public static final int latitude=0x7f06001c;
public static final int longitude=0x7f06001d;
public static final int menu_info=0x7f06001e;
public static final int menu_info_about=0x7f060020;
public static final int menu_info_map_file=0x7f06001f;
public static final int menu_mapfile=0x7f060021;
public static final int menu_options=0x7f060055;
public static final int menu_position=0x7f060022;
public static final int menu_position_enter_coordinates=0x7f060023;
public static final int menu_position_last_known=0x7f060024;
public static final int menu_position_map_file_center=0x7f060025;
public static final int menu_position_my_location_disable=0x7f060027;
public static final int menu_position_my_location_enable=0x7f060026;
public static final int menu_preferences=0x7f060028;
public static final int menu_render_theme=0x7f060029;
public static final int menu_render_theme_osmarender=0x7f06002a;
public static final int menu_render_theme_select_file=0x7f06002b;
public static final int menu_screenshot=0x7f06002c;
public static final int menu_screenshot_jpeg=0x7f06002d;
public static final int menu_screenshot_png=0x7f06002e;
public static final int no_location_provider_available=0x7f06002f;
public static final int ok=0x7f060030;
public static final int preferences_cache_persistence=0x7f060033;
public static final int preferences_cache_persistence_desc=0x7f060034;
public static final int preferences_cache_size=0x7f060035;
public static final int preferences_cache_size_desc=0x7f060036;
public static final int preferences_cache_size_value=0x7f060037;
public static final int preferences_debug=0x7f060031;
public static final int preferences_disable_polygons=0x7f06004a;
public static final int preferences_fullscreen=0x7f060038;
public static final int preferences_fullscreen_desc=0x7f060039;
public static final int preferences_general=0x7f060032;
public static final int preferences_map=0x7f06003a;
public static final int preferences_map_database_default=0x7f060000;
public static final int preferences_map_view_mode=0x7f06003b;
public static final int preferences_map_view_mode_desc=0x7f06003c;
public static final int preferences_move_speed=0x7f06003d;
public static final int preferences_move_speed_desc=0x7f06003e;
public static final int preferences_move_speed_value=0x7f06003f;
public static final int preferences_scale_bar_unit=0x7f060040;
public static final int preferences_scale_bar_unit_default=0x7f060001;
public static final int preferences_scale_bar_unit_desc=0x7f060041;
public static final int preferences_show_fps_counter=0x7f060042;
public static final int preferences_show_fps_counter_desc=0x7f060043;
public static final int preferences_show_scale_bar=0x7f060044;
public static final int preferences_show_scale_bar_desc=0x7f060045;
public static final int preferences_show_tile_coordinates=0x7f060046;
public static final int preferences_show_tile_coordinates_desc=0x7f060047;
public static final int preferences_show_tile_frames=0x7f060048;
public static final int preferences_show_tile_frames_desc=0x7f060049;
public static final int preferences_show_water_tiles=0x7f060057;
public static final int preferences_show_water_tiles_desc=0x7f06004b;
public static final int preferences_text_scale=0x7f06004c;
public static final int preferences_text_scale_default=0x7f060002;
public static final int preferences_text_scale_desc=0x7f06004d;
public static final int preferences_wake_lock=0x7f06004e;
public static final int preferences_wake_lock_desc=0x7f06004f;
public static final int snap_to_location_disabled=0x7f060051;
public static final int snap_to_location_enabled=0x7f060050;
public static final int unit_symbol_kilometer=0x7f060052;
public static final int unit_symbol_meter=0x7f060053;
public static final int zoomLevel=0x7f060054;
}
public static final class style {
public static final int MyActionBar=0x7f070000;
/**
<item name="android:dropDownListViewStyle">@style/MyDropDownListView</item>
<item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
<item name="android:actionDropDownStyle">@style/MyDropDownNav</item>
<item name="android:listChoiceIndicatorMultiple">@drawable/ad_btn_check_holo_light</item>
<item name="android:listChoiceIndicatorSingle">@drawable/ad_btn_radio_holo_light</item>
*/
public static final int Theme_TileMap=0x7f070001;
}
public static final class xml {
public static final int preferences=0x7f040000;
}
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainView"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<org.mapsforge.android.MapView
android:id="@+id/mapView"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<ToggleButton
android:id="@+id/snapToLocationView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="10dip"
android:layout_marginTop="10dip"
android:background="@drawable/snap_to_position"
android:textOff=""
android:textOn=""
android:visibility="gone" />
</RelativeLayout>

View File

@ -14,13 +14,10 @@
*/ */
package org.mapsforge.android; package org.mapsforge.android;
import java.io.Serializable;
/** /**
* A simple DTO to stores flags for debugging rendered map tiles. * A simple DTO to stores flags for debugging rendered map tiles.
*/ */
public class DebugSettings implements Serializable { public class DebugSettings {
private static final long serialVersionUID = 1L;
/** /**
* True if drawing of tile coordinates is enabled, false otherwise. * True if drawing of tile coordinates is enabled, false otherwise.
@ -47,7 +44,8 @@ public class DebugSettings implements Serializable {
* @param disablePolygons * @param disablePolygons
* if highlighting of water tiles is enabled. * if highlighting of water tiles is enabled.
*/ */
public DebugSettings(boolean drawTileCoordinates, boolean drawTileFrames, boolean disablePolygons) { public DebugSettings(boolean drawTileCoordinates, boolean drawTileFrames,
boolean disablePolygons) {
mDrawTileCoordinates = drawTileCoordinates; mDrawTileCoordinates = drawTileCoordinates;
mDrawTileFrames = drawTileFrames; mDrawTileFrames = drawTileFrames;
mDisablePolygons = disablePolygons; mDisablePolygons = disablePolygons;

View File

@ -14,7 +14,6 @@
*/ */
package org.mapsforge.android; package org.mapsforge.android;
import org.mapsforge.android.mapgenerator.MapGenerator;
import org.mapsforge.core.GeoPoint; import org.mapsforge.core.GeoPoint;
import org.mapsforge.core.MapPosition; import org.mapsforge.core.MapPosition;
@ -64,10 +63,7 @@ public abstract class MapActivity extends Activity {
MODE_PRIVATE); MODE_PRIVATE);
if (containsMapViewPosition(sharedPreferences)) { if (containsMapViewPosition(sharedPreferences)) {
MapGenerator mapGenerator = mapView.getMapGenerator(); if (sharedPreferences.contains(KEY_MAP_FILE)) {
if (!mapGenerator.requiresInternetConnection()
&& sharedPreferences.contains(KEY_MAP_FILE)) {
// get and set the map file // get and set the map file
mapView.setMapFile(sharedPreferences.getString(KEY_MAP_FILE, null)); mapView.setMapFile(sharedPreferences.getString(KEY_MAP_FILE, null));
} }
@ -106,8 +102,7 @@ public abstract class MapActivity extends Activity {
editor.putInt(KEY_ZOOM_LEVEL, mapPosition.zoomLevel); editor.putInt(KEY_ZOOM_LEVEL, mapPosition.zoomLevel);
} }
if (!mMapView.getMapGenerator().requiresInternetConnection() if (mMapView.getMapFile() != null) {
&& mMapView.getMapFile() != null) {
// save the map file // save the map file
editor.putString(KEY_MAP_FILE, mMapView.getMapFile()); editor.putString(KEY_MAP_FILE, mMapView.getMapFile());
} }

View File

@ -17,13 +17,13 @@ package org.mapsforge.android;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import org.mapsforge.android.inputhandling.TouchHandler; import org.mapsforge.android.input.TouchHandler;
import org.mapsforge.android.mapgenerator.IMapGenerator;
import org.mapsforge.android.mapgenerator.JobParameters; import org.mapsforge.android.mapgenerator.JobParameters;
import org.mapsforge.android.mapgenerator.JobQueue; import org.mapsforge.android.mapgenerator.JobQueue;
import org.mapsforge.android.mapgenerator.JobTheme; import org.mapsforge.android.mapgenerator.JobTheme;
import org.mapsforge.android.mapgenerator.MapDatabaseFactory; import org.mapsforge.android.mapgenerator.MapDatabaseFactory;
import org.mapsforge.android.mapgenerator.MapDatabaseInternal; import org.mapsforge.android.mapgenerator.MapDatabaseInternal;
import org.mapsforge.android.mapgenerator.MapGenerator;
import org.mapsforge.android.mapgenerator.MapGeneratorFactory; import org.mapsforge.android.mapgenerator.MapGeneratorFactory;
import org.mapsforge.android.mapgenerator.MapGeneratorInternal; import org.mapsforge.android.mapgenerator.MapGeneratorInternal;
import org.mapsforge.android.mapgenerator.MapWorker; import org.mapsforge.android.mapgenerator.MapWorker;
@ -49,7 +49,8 @@ import android.view.MotionEvent;
* <p> * <p>
* This implementation supports offline map rendering as well as downloading map images (tiles) over an Internet * This implementation supports offline map rendering as well as downloading map images (tiles) over an Internet
* connection. The operation mode of a MapView can be set in the constructor and changed at runtime with the * connection. The operation mode of a MapView can be set in the constructor and changed at runtime with the
* {@link #setMapGeneratorInternal(MapGenerator)} method. Some MapView parameters depend on the selected operation mode. * {@link #setMapGeneratorInternal(IMapGenerator)} method. Some MapView parameters depend on the selected operation
* mode.
* <p> * <p>
* In offline rendering mode a special database file is required which contains the map data. Map files can be stored in * In offline rendering mode a special database file is required which contains the map data. Map files can be stored in
* any folder. The current map file is set by calling {@link #setMapFile(String)}. To retrieve the current * any folder. The current map file is set by calling {@link #setMapFile(String)}. To retrieve the current
@ -79,7 +80,7 @@ public class MapView extends GLSurfaceView {
private final TouchHandler mTouchEventHandler; private final TouchHandler mTouchEventHandler;
private IMapDatabase mMapDatabase; private IMapDatabase mMapDatabase;
private MapGenerator mMapGenerator; private IMapGenerator mMapGenerator;
private MapRenderer mMapRenderer; private MapRenderer mMapRenderer;
private JobQueue mJobQueue; private JobQueue mJobQueue;
private MapWorker mMapWorker; private MapWorker mMapWorker;
@ -121,13 +122,13 @@ public class MapView extends GLSurfaceView {
* @throws IllegalArgumentException * @throws IllegalArgumentException
* if the context object is not an instance of {@link MapActivity} . * if the context object is not an instance of {@link MapActivity} .
*/ */
public MapView(Context context, MapGenerator mapGenerator) { public MapView(Context context, IMapGenerator mapGenerator) {
this(context, null, mapGenerator, MapDatabaseFactory this(context, null, mapGenerator, MapDatabaseFactory
.createMapDatabase(MapDatabaseInternal.MAP_READER)); .createMapDatabase(MapDatabaseInternal.MAP_READER));
} }
private MapView(Context context, AttributeSet attributeSet, private MapView(Context context, AttributeSet attributeSet,
MapGenerator mapGenerator, IMapDatabase mapDatabase) { IMapGenerator mapGenerator, IMapDatabase mapDatabase) {
super(context, attributeSet); super(context, attributeSet);
@ -147,9 +148,8 @@ public class MapView extends GLSurfaceView {
mMapController = new MapController(this); mMapController = new MapController(this);
// mMapDatabase = MapDatabaseFactory.createMapDatabase(MapDatabaseInternal.POSTGIS_READER); // mMapDatabase = MapDatabaseFactory.createMapDatabase(MapDatabaseInternal.POSTGIS_READER);
// mMapDatabase = MapDatabaseFactory.createMapDatabase(MapDatabaseInternal.JSON_READER);
mMapDatabase = mapDatabase; mMapDatabase = mapDatabase;
// MapDatabaseFactory
// .createMapDatabase(MapDatabaseInternal.MAP_READER);
mMapViewPosition = new MapViewPosition(this); mMapViewPosition = new MapViewPosition(this);
mMapScaleBar = new MapScaleBar(this); mMapScaleBar = new MapScaleBar(this);
@ -212,32 +212,22 @@ public class MapView extends GLSurfaceView {
/** /**
* @return the map database which is used for reading map files. * @return the map database which is used for reading map files.
* @throws UnsupportedOperationException
* if the current MapGenerator works with an Internet connection.
*/ */
public IMapDatabase getMapDatabase() { public IMapDatabase getMapDatabase() {
if (mMapGenerator.requiresInternetConnection()) {
throw new UnsupportedOperationException();
}
return mMapDatabase; return mMapDatabase;
} }
/** /**
* @return the currently used map file. * @return the currently used map file.
* @throws UnsupportedOperationException
* if the current MapGenerator mode works with an Internet connection.
*/ */
public String getMapFile() { public String getMapFile() {
if (mMapGenerator.requiresInternetConnection()) {
throw new UnsupportedOperationException();
}
return mMapFile; return mMapFile;
} }
/** /**
* @return the currently used MapGenerator (may be null). * @return the currently used MapGenerator (may be null).
*/ */
public MapGenerator getMapGenerator() { public IMapGenerator getMapGenerator() {
return mMapGenerator; return mMapGenerator;
} }
@ -359,24 +349,12 @@ public class MapView extends GLSurfaceView {
* @param mapFile * @param mapFile
* the path to the map file. * the path to the map file.
* @return true if the map file was set correctly, false otherwise. * @return true if the map file was set correctly, false otherwise.
* @throws UnsupportedOperationException
* if the current MapGenerator mode works with an Internet connection.
*/ */
public boolean setMapFile(String mapFile) { public boolean setMapFile(String mapFile) {
FileOpenResult fileOpenResult = null; FileOpenResult fileOpenResult = null;
if (mMapGenerator.requiresInternetConnection()) {
throw new UnsupportedOperationException();
}
Log.d(TAG, "set mapfile " + mapFile); Log.d(TAG, "set mapfile " + mapFile);
// if (mapFile == null) {
// if (mMapDatabase instanceof org.mapsforge.database.postgis.MapDatabase) {
// fileOpenResult = mMapDatabase.openFile(null);
// } else {
// // no map file specified
// return false;
// }
// } else
if (mapFile != null && mapFile.equals(mMapFile)) { if (mapFile != null && mapFile.equals(mMapFile)) {
// same map file as before // same map file as before
return false; return false;
@ -419,9 +397,10 @@ public class MapView extends GLSurfaceView {
Log.d(TAG, "mapfile set"); Log.d(TAG, "mapfile set");
return true; return true;
} }
mMapFile = null; mMapFile = null;
// clearAndRedrawMapView();
Log.d(TAG, "loading mapfile failed"); Log.d(TAG, "loading mapfile failed");
return false; return false;
} }
@ -431,7 +410,7 @@ public class MapView extends GLSurfaceView {
* @param mapGenerator * @param mapGenerator
* the new MapGenerator. * the new MapGenerator.
*/ */
public void setMapGenerator(MapGenerator mapGenerator) { public void setMapGenerator(IMapGenerator mapGenerator) {
if (mMapGenerator != mapGenerator) { if (mMapGenerator != mapGenerator) {
setMapGeneratorInternal(mapGenerator); setMapGeneratorInternal(mapGenerator);
@ -440,7 +419,7 @@ public class MapView extends GLSurfaceView {
} }
} }
private void setMapGeneratorInternal(MapGenerator mapGenerator) { private void setMapGeneratorInternal(IMapGenerator mapGenerator) {
if (mapGenerator == null) { if (mapGenerator == null) {
throw new IllegalArgumentException("mapGenerator must not be null"); throw new IllegalArgumentException("mapGenerator must not be null");
} }
@ -504,15 +483,12 @@ public class MapView extends GLSurfaceView {
* the internal rendering theme. * the internal rendering theme.
* @throws IllegalArgumentException * @throws IllegalArgumentException
* if the supplied internalRenderTheme is null. * if the supplied internalRenderTheme is null.
* @throws UnsupportedOperationException
* if the current MapGenerator does not support render themes.
*/ */
public void setRenderTheme(InternalRenderTheme internalRenderTheme) { public void setRenderTheme(InternalRenderTheme internalRenderTheme) {
if (internalRenderTheme == null) { if (internalRenderTheme == null) {
throw new IllegalArgumentException("render theme must not be null"); throw new IllegalArgumentException("render theme must not be null");
} else if (mMapGenerator.requiresInternetConnection()) {
throw new UnsupportedOperationException();
} }
Log.d(TAG, "set rendertheme " + internalRenderTheme); Log.d(TAG, "set rendertheme " + internalRenderTheme);
mJobParameters = new JobParameters(internalRenderTheme, mJobParameters.textScale); mJobParameters = new JobParameters(internalRenderTheme, mJobParameters.textScale);
@ -526,16 +502,12 @@ public class MapView extends GLSurfaceView {
* the path to the XML file which defines the rendering theme. * the path to the XML file which defines the rendering theme.
* @throws IllegalArgumentException * @throws IllegalArgumentException
* if the supplied internalRenderTheme is null. * if the supplied internalRenderTheme is null.
* @throws UnsupportedOperationException
* if the current MapGenerator does not support render themes.
* @throws FileNotFoundException * @throws FileNotFoundException
* if the supplied file does not exist, is a directory or cannot be read. * if the supplied file does not exist, is a directory or cannot be read.
*/ */
public void setRenderTheme(String renderThemePath) throws FileNotFoundException { public void setRenderTheme(String renderThemePath) throws FileNotFoundException {
if (renderThemePath == null) { if (renderThemePath == null) {
throw new IllegalArgumentException("render theme path must not be null"); throw new IllegalArgumentException("render theme path must not be null");
} else if (mMapGenerator.requiresInternetConnection()) {
throw new UnsupportedOperationException();
} }
JobTheme jobTheme = new ExternalRenderTheme(renderThemePath); JobTheme jobTheme = new ExternalRenderTheme(renderThemePath);
@ -650,10 +622,9 @@ public class MapView extends GLSurfaceView {
boolean hasValidCenter() { boolean hasValidCenter() {
if (!mMapViewPosition.isValid()) { if (!mMapViewPosition.isValid()) {
return false; return false;
} else if (!mMapGenerator.requiresInternetConnection() } else if (!mMapDatabase.hasOpenFile()
&& (!mMapDatabase.hasOpenFile() || !mMapDatabase.getMapFileInfo().boundingBox || !mMapDatabase.getMapFileInfo().boundingBox.contains(getMapPosition()
.contains(getMapPosition() .getMapCenter())) {
.getMapCenter()))) {
return false; return false;
} }

View File

@ -14,7 +14,7 @@
*/ */
package org.mapsforge.android; package org.mapsforge.android;
import org.mapsforge.android.mapgenerator.MapGenerator; import org.mapsforge.android.mapgenerator.IMapGenerator;
import android.content.Context; import android.content.Context;
import android.os.Handler; import android.os.Handler;
@ -179,7 +179,7 @@ public class MapZoomControls {
/** /**
* Sets the maximum zoom level of the map. * Sets the maximum zoom level of the map.
* <p> * <p>
* The maximum possible zoom level of the MapView depends also on the current {@link MapGenerator}. For example, * The maximum possible zoom level of the MapView depends also on the current {@link IMapGenerator}. For example,
* downloading map tiles may only be possible up to a certain zoom level. Setting a higher maximum zoom level has no * downloading map tiles may only be possible up to a certain zoom level. Setting a higher maximum zoom level has no
* effect in this case. * effect in this case.
* *

View File

@ -21,16 +21,16 @@ import java.util.ArrayList;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import org.mapsforge.android.MapView; import org.mapsforge.android.MapView;
import org.mapsforge.android.mapgenerator.IMapGenerator;
import org.mapsforge.android.mapgenerator.JobTheme; import org.mapsforge.android.mapgenerator.JobTheme;
import org.mapsforge.android.mapgenerator.MapGenerator;
import org.mapsforge.android.mapgenerator.MapGeneratorJob; import org.mapsforge.android.mapgenerator.MapGeneratorJob;
import org.mapsforge.android.rendertheme.RenderCallback; import org.mapsforge.android.rendertheme.IRenderCallback;
import org.mapsforge.android.rendertheme.RenderTheme; import org.mapsforge.android.rendertheme.RenderTheme;
import org.mapsforge.android.rendertheme.RenderThemeHandler; import org.mapsforge.android.rendertheme.RenderThemeHandler;
import org.mapsforge.android.rendertheme.renderinstruction.Area; import org.mapsforge.android.rendertheme.renderinstruction.Area;
import org.mapsforge.android.rendertheme.renderinstruction.Line; import org.mapsforge.android.rendertheme.renderinstruction.Line;
import org.mapsforge.core.GeoPoint; import org.mapsforge.core.GeoPoint;
import org.mapsforge.core.SphericalMercator; import org.mapsforge.core.WebMercator;
import org.mapsforge.core.Tag; import org.mapsforge.core.Tag;
import org.mapsforge.core.Tile; import org.mapsforge.core.Tile;
import org.mapsforge.database.IMapDatabase; import org.mapsforge.database.IMapDatabase;
@ -46,7 +46,7 @@ import android.util.Log;
/** /**
* *
*/ */
public class DatabaseRenderer implements MapGenerator, RenderCallback, public class DatabaseRenderer implements IMapGenerator, IRenderCallback,
IMapDatabaseCallback { IMapDatabaseCallback {
private static String TAG = DatabaseRenderer.class.getName(); private static String TAG = DatabaseRenderer.class.getName();
@ -80,6 +80,8 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback,
private int mDrawingLayer; private int mDrawingLayer;
private int mLevels; private int mLevels;
private boolean useSphericalMercator = false;
/** /**
* *
*/ */
@ -420,7 +422,7 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback,
if (mMapDatabase != null && mMapDatabase.hasOpenFile()) { if (mMapDatabase != null && mMapDatabase.hasOpenFile()) {
MapFileInfo mapFileInfo = mMapDatabase.getMapFileInfo(); MapFileInfo mapFileInfo = mMapDatabase.getMapFileInfo();
if (SphericalMercator.NAME.equals(mapFileInfo.projectionName)) { if (WebMercator.NAME.equals(mapFileInfo.projectionName)) {
Log.d(TAG, "using Spherical Mercator"); Log.d(TAG, "using Spherical Mercator");
useSphericalMercator = true; useSphericalMercator = true;
@ -445,11 +447,6 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback,
return ZOOM_MAX; return ZOOM_MAX;
} }
@Override
public boolean requiresInternetConnection() {
return false;
}
private static boolean setRenderTheme(JobTheme jobTheme) { private static boolean setRenderTheme(JobTheme jobTheme) {
InputStream inputStream = null; InputStream inputStream = null;
try { try {
@ -489,8 +486,6 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback,
return new MapRenderer(mapView); return new MapRenderer(mapView);
} }
private boolean useSphericalMercator = false;
@Override @Override
public void setMapDatabase(IMapDatabase mapDatabase) { public void setMapDatabase(IMapDatabase mapDatabase) {
mMapDatabase = mapDatabase; mMapDatabase = mapDatabase;

View File

@ -26,7 +26,7 @@ import javax.microedition.khronos.opengles.GL10;
import org.mapsforge.android.DebugSettings; import org.mapsforge.android.DebugSettings;
import org.mapsforge.android.MapView; import org.mapsforge.android.MapView;
import org.mapsforge.android.mapgenerator.JobParameters; import org.mapsforge.android.mapgenerator.JobParameters;
import org.mapsforge.android.mapgenerator.MapGenerator; import org.mapsforge.android.mapgenerator.IMapGenerator;
import org.mapsforge.android.mapgenerator.MapGeneratorJob; import org.mapsforge.android.mapgenerator.MapGeneratorJob;
import org.mapsforge.android.mapgenerator.MapWorker; import org.mapsforge.android.mapgenerator.MapWorker;
import org.mapsforge.android.mapgenerator.TileCacheKey; import org.mapsforge.android.mapgenerator.TileCacheKey;
@ -316,7 +316,7 @@ public class MapRenderer implements org.mapsforge.android.MapRenderer {
mJobList.clear(); mJobList.clear();
mJobParameter = mMapView.getJobParameters(); mJobParameter = mMapView.getJobParameters();
MapGenerator mapGenerator = mMapView.getMapGenerator(); IMapGenerator mapGenerator = mMapView.getMapGenerator();
int tiles = 0; int tiles = 0;
if (newTiles == null) if (newTiles == null)
return false; return false;

View File

@ -61,14 +61,7 @@ public class MeshLayer extends Layer {
curVertices[outPos++] = (float) tri.points[i].getY(); curVertices[outPos++] = (float) tri.points[i].getY();
} }
// System.out.println("" +
// (float) tri.points[0].getX() + "/" + (float) tri.points[0].getY()
// + ", " +
// (float) tri.points[1].getX() + "/" + (float) tri.points[1].getY()
// + ", " +
// (float) tri.points[2].getX() + "/" + (float) tri.points[2].getY());
} }
// System.out.println("---");
curItem.used = outPos; curItem.used = outPos;
verticesCnt += poly.getTriangles().size() * 3; verticesCnt += poly.getTriangles().size() * 3;
} }

View File

@ -34,7 +34,7 @@ public class MeshLayers {
size = 0; size = 0;
} }
MeshLayer getLayer(int layer, int color, int fade) { MeshLayer getLayer(int layer, int color) {
MeshLayer l = layers.get(layer); MeshLayer l = layers.get(layer);
if (l != null) { if (l != null) {
return l; return l;

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with * 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/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.mapsforge.android.inputhandling; package org.mapsforge.android.input;
import org.mapsforge.android.MapView; import org.mapsforge.android.MapView;
import org.mapsforge.android.utils.PausableThread; import org.mapsforge.android.utils.PausableThread;

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with * 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/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.mapsforge.android.inputhandling; package org.mapsforge.android.input;
import org.mapsforge.android.MapView; import org.mapsforge.android.MapView;
import org.mapsforge.android.MapViewPosition; import org.mapsforge.android.MapViewPosition;
@ -21,10 +21,14 @@ import android.view.ScaleGestureDetector;
class ScaleListener implements ScaleGestureDetector.OnScaleGestureListener { class ScaleListener implements ScaleGestureDetector.OnScaleGestureListener {
private final MapView mMapView; private final MapView mMapView;
private float mFocusX;
private float mFocusY;
private MapViewPosition mMapPosition; private MapViewPosition mMapPosition;
private float mCenterX;
private float mCenterY;
// private float mFocusX;
// private float mFocusY;
private float mScale;
// private boolean mScaling;
/** /**
* Creates a new ScaleListener for the given MapView. * Creates a new ScaleListener for the given MapView.
* *
@ -37,23 +41,46 @@ class ScaleListener implements ScaleGestureDetector.OnScaleGestureListener {
@Override @Override
public boolean onScale(ScaleGestureDetector scaleGestureDetector) { public boolean onScale(ScaleGestureDetector scaleGestureDetector) {
float scaleFactor = scaleGestureDetector.getScaleFactor();
mMapPosition.scaleMap(scaleFactor, mFocusX, mFocusY); float focusX = scaleGestureDetector.getFocusX();
float focusY = scaleGestureDetector.getFocusY();
mScale = scaleGestureDetector.getScaleFactor();
// mMapPosition.moveMap((focusX - mFocusX), (focusY - mFocusY));
// if (mScale > 1.001 || mScale < 0.999) {
mMapPosition.scaleMap(mScale,
focusX - mCenterX,
focusY - mCenterY);
mMapView.redrawTiles(); mMapView.redrawTiles();
// mScale = 1;
// mFocusX = focusX;
// mFocusY = focusY;
// }
// else if (Math.abs(focusX - mFocusX) > 0.5 || Math.abs(focusY - mFocusY) > 0.5) {
// mMapPosition.moveMap((focusX - mFocusX), (focusY - mFocusY));
//
// mFocusX = focusX;
// mFocusY = focusY;
// mScale = 1;
// mMapView.redrawTiles();
// }
return true; return true;
} }
@Override @Override
public boolean onScaleBegin(ScaleGestureDetector scaleGestureDetector) { public boolean onScaleBegin(ScaleGestureDetector scaleGestureDetector) {
mFocusX = scaleGestureDetector.getFocusX();
mFocusY = scaleGestureDetector.getFocusY();
mFocusX -= ((mMapView.getWidth() >> 1)); mCenterX = mMapView.getWidth() >> 1;
mFocusY -= ((mMapView.getHeight() >> 1)); mCenterY = mMapView.getHeight() >> 1;
// mFocusX = scaleGestureDetector.getFocusX();
// mFocusY = scaleGestureDetector.getFocusY();
mScale = 1;
mMapPosition = mMapView.getMapPosition(); mMapPosition = mMapView.getMapPosition();
// mScaling = false;
return true; return true;
} }

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with * 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/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.mapsforge.android.inputhandling; package org.mapsforge.android.input;
import org.mapsforge.android.MapView; import org.mapsforge.android.MapView;
import org.mapsforge.core.Tile; import org.mapsforge.core.Tile;

View File

@ -12,7 +12,7 @@
* You should have received a copy of the GNU Lesser General Public License along with * 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/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.mapsforge.android.inputhandling; package org.mapsforge.android.input;
import org.mapsforge.android.MapView; import org.mapsforge.android.MapView;
import org.mapsforge.android.utils.PausableThread; import org.mapsforge.android.utils.PausableThread;

View File

@ -22,7 +22,7 @@ import org.mapsforge.database.IMapDatabase;
/** /**
* A MapGenerator provides map tiles either by downloading or rendering them. * A MapGenerator provides map tiles either by downloading or rendering them.
*/ */
public interface MapGenerator { public interface IMapGenerator {
/** /**
* Called once at the end of the MapGenerator lifecycle. * Called once at the end of the MapGenerator lifecycle.
*/ */
@ -52,11 +52,6 @@ public interface MapGenerator {
*/ */
byte getZoomLevelMax(); byte getZoomLevelMax();
/**
* @return true if this MapGenerator requires an Internet connection, false otherwise.
*/
boolean requiresInternetConnection();
/** /**
* @param mapView * @param mapView
* the MapView * the MapView

View File

@ -14,13 +14,10 @@
*/ */
package org.mapsforge.android.mapgenerator; package org.mapsforge.android.mapgenerator;
import java.io.Serializable;
/** /**
* A JobParameters instance is a simple DTO to store the rendering parameters for a job. * A JobParameters instance is a simple DTO to store the rendering parameters for a job.
*/ */
public class JobParameters implements Serializable { public class JobParameters {
private static final long serialVersionUID = 1L;
/** /**
* The render theme which should be used. * The render theme which should be used.

View File

@ -0,0 +1,43 @@
/*
* Copyright 2010, 2011, 2012 mapsforge.org
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* 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.android.mapgenerator;
import org.mapsforge.android.utils.PausableThread;
public class MapDownloader extends PausableThread {
private static final String THREAD_NAME = "MapDownloader";
@Override
protected void doWork() {
// TODO Auto-generated method stub
}
@Override
protected boolean hasWork() {
// TODO Auto-generated method stub
return false;
}
@Override
protected String getThreadName() {
return THREAD_NAME;
}
@Override
protected int getThreadPriority() {
return (Thread.NORM_PRIORITY + Thread.MIN_PRIORITY) / 2;
}
}

View File

@ -27,7 +27,7 @@ public final class MapGeneratorFactory {
* A collection of attributes which includes the desired MapGenerator. * A collection of attributes which includes the desired MapGenerator.
* @return a new MapGenerator instance. * @return a new MapGenerator instance.
*/ */
public static MapGenerator createMapGenerator(AttributeSet attributeSet) { public static IMapGenerator createMapGenerator(AttributeSet attributeSet) {
String mapGeneratorName = attributeSet.getAttributeValue(null, MAP_GENERATOR_ATTRIBUTE_NAME); String mapGeneratorName = attributeSet.getAttributeValue(null, MAP_GENERATOR_ATTRIBUTE_NAME);
if (mapGeneratorName == null) { if (mapGeneratorName == null) {
return new org.mapsforge.android.glrenderer.DatabaseRenderer(); return new org.mapsforge.android.glrenderer.DatabaseRenderer();
@ -42,7 +42,7 @@ public final class MapGeneratorFactory {
* the internal MapGenerator implementation. * the internal MapGenerator implementation.
* @return a new MapGenerator instance. * @return a new MapGenerator instance.
*/ */
public static MapGenerator createMapGenerator(MapGeneratorInternal mapGeneratorInternal) { public static IMapGenerator createMapGenerator(MapGeneratorInternal mapGeneratorInternal) {
switch (mapGeneratorInternal) { switch (mapGeneratorInternal) {
case SW_RENDERER: case SW_RENDERER:
return new org.mapsforge.android.swrenderer.DatabaseRenderer(); return new org.mapsforge.android.swrenderer.DatabaseRenderer();

View File

@ -45,7 +45,7 @@ public class MapGeneratorJob implements Comparable<MapGeneratorJob>, Serializabl
public final MapTile tile; public final MapTile tile;
private transient int mHashCodeValue; private transient int mHashCodeValue;
private final MapGenerator mMapGenerator; private final IMapGenerator mMapGenerator;
private transient double mPriority; private transient double mPriority;
/** /**
@ -97,7 +97,7 @@ public class MapGeneratorJob implements Comparable<MapGeneratorJob>, Serializabl
* @param _debugSettings * @param _debugSettings
* the debug settings for this job. * the debug settings for this job.
*/ */
public MapGeneratorJob(MapTile _tile, MapGenerator mapGenerator, public MapGeneratorJob(MapTile _tile, IMapGenerator mapGenerator,
JobParameters _jobParameters, DebugSettings _debugSettings) { JobParameters _jobParameters, DebugSettings _debugSettings) {
tile = _tile; tile = _tile;
mMapGenerator = mapGenerator; mMapGenerator = mapGenerator;

View File

@ -19,14 +19,14 @@ import org.mapsforge.android.MapView;
import org.mapsforge.android.utils.PausableThread; import org.mapsforge.android.utils.PausableThread;
/** /**
* A MapWorker uses a {@link MapGenerator} to generate map tiles. It runs in a separate thread to avoid blocking the UI * A MapWorker uses a {@link IMapGenerator} to generate map tiles. It runs in a separate thread to avoid blocking the UI
* thread. * thread.
*/ */
public class MapWorker extends PausableThread { public class MapWorker extends PausableThread {
private static final String THREAD_NAME = "MapWorker"; private static final String THREAD_NAME = "MapWorker";
private final JobQueue mJobQueue; private final JobQueue mJobQueue;
private MapGenerator mMapGenerator; private IMapGenerator mMapGenerator;
private MapRenderer mMapRenderer; private MapRenderer mMapRenderer;
/** /**
@ -42,7 +42,7 @@ public class MapWorker extends PausableThread {
* @param mapGenerator * @param mapGenerator
* the MapGenerator which this MapWorker should use. * the MapGenerator which this MapWorker should use.
*/ */
public void setMapGenerator(MapGenerator mapGenerator) { public void setMapGenerator(IMapGenerator mapGenerator) {
mMapGenerator = mapGenerator; mMapGenerator = mapGenerator;
} }

View File

@ -14,7 +14,7 @@
*/ */
package org.mapsforge.android.rendertheme; package org.mapsforge.android.rendertheme;
class Closed { final class Closed {
public static final int ANY = 0; public static final int ANY = 0;
public static final int NO = 1; public static final int NO = 1;
public static final int YES = 2; public static final int YES = 2;

View File

@ -14,7 +14,7 @@
*/ */
package org.mapsforge.android.rendertheme; package org.mapsforge.android.rendertheme;
class Element { final class Element {
public static final int ANY = 0; public static final int ANY = 0;
public static final int NODE = 1; public static final int NODE = 1;
public static final int WAY = 2; public static final int WAY = 2;

View File

@ -23,7 +23,7 @@ import android.graphics.Paint;
/** /**
* Callback methods for rendering areas, ways and points of interest (POIs). * Callback methods for rendering areas, ways and points of interest (POIs).
*/ */
public interface RenderCallback { public interface IRenderCallback {
/** /**
* Renders an area with the given parameters. * Renders an area with the given parameters.
* *

View File

@ -141,7 +141,7 @@ public class RenderTheme {
* @param zoomLevel * @param zoomLevel
* ... * ...
*/ */
public void matchNode(RenderCallback renderCallback, Tag[] tags, byte zoomLevel) { public void matchNode(IRenderCallback renderCallback, Tag[] tags, byte zoomLevel) {
// List<RenderInstruction> matchingList = matchingListNode; // List<RenderInstruction> matchingList = matchingListNode;
// MatchingCacheKey matchingCacheKey = matchingCacheKeyNode; // MatchingCacheKey matchingCacheKey = matchingCacheKeyNode;
// //
@ -214,7 +214,7 @@ public class RenderTheme {
* @param changed * @param changed
* ... * ...
*/ */
public void matchWay(RenderCallback renderCallback, Tag[] tags, byte zoomLevel, public void matchWay(IRenderCallback renderCallback, Tag[] tags, byte zoomLevel,
boolean closed, boolean changed) { boolean closed, boolean changed) {
RenderInstruction[] renderInstructions = null; RenderInstruction[] renderInstructions = null;

View File

@ -189,7 +189,7 @@ abstract class Rule {
abstract boolean matchesWay(Tag[] tags, byte zoomLevel, int closed); abstract boolean matchesWay(Tag[] tags, byte zoomLevel, int closed);
void matchNode(RenderCallback renderCallback, Tag[] tags, byte zoomLevel) { void matchNode(IRenderCallback renderCallback, Tag[] tags, byte zoomLevel) {
if (matchesNode(tags, zoomLevel)) { if (matchesNode(tags, zoomLevel)) {
for (int i = 0, n = mRenderInstructionArray.length; i < n; i++) for (int i = 0, n = mRenderInstructionArray.length; i < n; i++)
mRenderInstructionArray[i].renderNode(renderCallback, tags); mRenderInstructionArray[i].renderNode(renderCallback, tags);
@ -200,7 +200,7 @@ abstract class Rule {
} }
} }
void matchWay(RenderCallback renderCallback, Tag[] tags, byte zoomLevel, void matchWay(IRenderCallback renderCallback, Tag[] tags, byte zoomLevel,
int closed, int closed,
List<RenderInstruction> matchingList) { List<RenderInstruction> matchingList) {

View File

@ -15,10 +15,9 @@
package org.mapsforge.android.rendertheme; package org.mapsforge.android.rendertheme;
import java.util.Stack; import java.util.Stack;
import java.util.logging.Logger;
final class RuleOptimizer { final class RuleOptimizer {
private static final Logger LOG = Logger.getLogger(RuleOptimizer.class.getName()); // private static final Logger LOG = Logger.getLogger(RuleOptimizer.class.getName());
private static AttributeMatcher optimizeKeyMatcher(AttributeMatcher attributeMatcher, private static AttributeMatcher optimizeKeyMatcher(AttributeMatcher attributeMatcher,
Stack<Rule> ruleStack) { Stack<Rule> ruleStack) {

View File

@ -9,12 +9,12 @@
<!-- landuse --> <!-- landuse -->
<rule e="way" k="landuse" v="*"> <rule e="way" k="landuse" v="*">
<rule e="way" k="*" zoom-min="12" v="farmland|farm"> <rule e="way" k="*" zoom-min="10" v="farmland|farm">
<area fill="#fff8bf" fade="12" /> <area fill="#fff8bf" fade="10" />
</rule> </rule>
<rule e="way" k="landuse" v="grass"> <rule e="way" k="landuse" zoom-min="10" v="grass">
<area fill="#deecb9" fade="12" /> <area fill="#deecb9" fade="10" />
</rule> </rule>
<rule e="way" k="*" zoom-min="10" v="residential|farmyard|retail|commercial"> <rule e="way" k="*" zoom-min="10" v="residential|farmyard|retail|commercial">
@ -334,7 +334,7 @@
</rule>--> </rule>-->
<rule e="way" k="*" v="*" zoom-min="15"> <rule e="way" k="*" v="*" zoom-min="15">
<line stroke="#c9c3c1" stroke-width="0.6" fixed="true" stroke-linecap="butt" /> <line stroke="#c9c3c1" stroke-width="0.6" fixed="true" stroke-linecap="butt" />
<area fill="#e9e6e3" fade="15" /> <area fill="#e9e6e3" fade="15" />
</rule> </rule>

View File

@ -16,7 +16,7 @@ package org.mapsforge.android.rendertheme.renderinstruction;
import java.io.IOException; import java.io.IOException;
import org.mapsforge.android.rendertheme.RenderCallback; import org.mapsforge.android.rendertheme.IRenderCallback;
import org.mapsforge.android.rendertheme.RenderThemeHandler; import org.mapsforge.android.rendertheme.RenderThemeHandler;
import org.mapsforge.core.Tag; import org.mapsforge.core.Tag;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
@ -137,12 +137,12 @@ public final class Area implements RenderInstruction {
} }
@Override @Override
public void renderNode(RenderCallback renderCallback, Tag[] tags) { public void renderNode(IRenderCallback renderCallback, Tag[] tags) {
// do nothing // do nothing
} }
@Override @Override
public void renderWay(RenderCallback renderCallback, Tag[] tags) { public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
if (paintFill != null) { if (paintFill != null) {
renderCallback.renderArea(this); renderCallback.renderArea(this);
} }

View File

@ -16,7 +16,7 @@ package org.mapsforge.android.rendertheme.renderinstruction;
import java.util.Locale; import java.util.Locale;
import org.mapsforge.android.rendertheme.RenderCallback; import org.mapsforge.android.rendertheme.IRenderCallback;
import org.mapsforge.android.rendertheme.RenderThemeHandler; import org.mapsforge.android.rendertheme.RenderThemeHandler;
import org.mapsforge.core.Tag; import org.mapsforge.core.Tag;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
@ -121,12 +121,12 @@ public final class Caption implements RenderInstruction {
} }
@Override @Override
public void renderNode(RenderCallback renderCallback, Tag[] tags) { public void renderNode(IRenderCallback renderCallback, Tag[] tags) {
renderCallback.renderPointOfInterestCaption(mTextKey, mDy, mPaint, mStroke); renderCallback.renderPointOfInterestCaption(mTextKey, mDy, mPaint, mStroke);
} }
@Override @Override
public void renderWay(RenderCallback renderCallback, Tag[] tags) { public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
renderCallback.renderAreaCaption(mTextKey, mDy, mPaint, mStroke); renderCallback.renderAreaCaption(mTextKey, mDy, mPaint, mStroke);
} }

View File

@ -14,7 +14,7 @@
*/ */
package org.mapsforge.android.rendertheme.renderinstruction; package org.mapsforge.android.rendertheme.renderinstruction;
import org.mapsforge.android.rendertheme.RenderCallback; import org.mapsforge.android.rendertheme.IRenderCallback;
import org.mapsforge.android.rendertheme.RenderThemeHandler; import org.mapsforge.android.rendertheme.RenderThemeHandler;
import org.mapsforge.core.Tag; import org.mapsforge.core.Tag;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
@ -123,7 +123,7 @@ public final class Circle implements RenderInstruction {
} }
@Override @Override
public void renderNode(RenderCallback renderCallback, Tag[] tags) { public void renderNode(IRenderCallback renderCallback, Tag[] tags) {
if (mOutline != null) { if (mOutline != null) {
renderCallback.renderPointOfInterestCircle(mRenderRadius, mOutline, mLevel); renderCallback.renderPointOfInterestCircle(mRenderRadius, mOutline, mLevel);
} }
@ -133,7 +133,7 @@ public final class Circle implements RenderInstruction {
} }
@Override @Override
public void renderWay(RenderCallback renderCallback, Tag[] tags) { public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
// do nothing // do nothing
} }

View File

@ -18,7 +18,7 @@ import java.io.IOException;
import java.util.Locale; import java.util.Locale;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.mapsforge.android.rendertheme.RenderCallback; import org.mapsforge.android.rendertheme.IRenderCallback;
import org.mapsforge.android.rendertheme.RenderThemeHandler; import org.mapsforge.android.rendertheme.RenderThemeHandler;
import org.mapsforge.core.Tag; import org.mapsforge.core.Tag;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
@ -164,12 +164,12 @@ public final class Line implements RenderInstruction {
} }
@Override @Override
public void renderNode(RenderCallback renderCallback, Tag[] tags) { public void renderNode(IRenderCallback renderCallback, Tag[] tags) {
// do nothing // do nothing
} }
@Override @Override
public void renderWay(RenderCallback renderCallback, Tag[] tags) { public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
// renderCallback.renderWay(mPaint, mLevel, mColor, mStrokeWidth, mRound, mOutline); // renderCallback.renderWay(mPaint, mLevel, mColor, mStrokeWidth, mRound, mOutline);
renderCallback.renderWay(this); renderCallback.renderWay(this);
} }

View File

@ -16,7 +16,7 @@ package org.mapsforge.android.rendertheme.renderinstruction;
import java.io.IOException; import java.io.IOException;
import org.mapsforge.android.rendertheme.RenderCallback; import org.mapsforge.android.rendertheme.IRenderCallback;
import org.mapsforge.android.rendertheme.RenderThemeHandler; import org.mapsforge.android.rendertheme.RenderThemeHandler;
import org.mapsforge.core.Tag; import org.mapsforge.core.Tag;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
@ -84,12 +84,12 @@ public final class LineSymbol implements RenderInstruction {
} }
@Override @Override
public void renderNode(RenderCallback renderCallback, Tag[] tags) { public void renderNode(IRenderCallback renderCallback, Tag[] tags) {
// do nothing // do nothing
} }
@Override @Override
public void renderWay(RenderCallback renderCallback, Tag[] tags) { public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
renderCallback.renderWaySymbol(mBitmap, mAlignCenter, mRepeat); renderCallback.renderWaySymbol(mBitmap, mAlignCenter, mRepeat);
} }

View File

@ -16,7 +16,7 @@ package org.mapsforge.android.rendertheme.renderinstruction;
import java.util.Locale; import java.util.Locale;
import org.mapsforge.android.rendertheme.RenderCallback; import org.mapsforge.android.rendertheme.IRenderCallback;
import org.mapsforge.android.rendertheme.RenderThemeHandler; import org.mapsforge.android.rendertheme.RenderThemeHandler;
import org.mapsforge.core.Tag; import org.mapsforge.core.Tag;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
@ -116,12 +116,12 @@ public final class PathText implements RenderInstruction {
} }
@Override @Override
public void renderNode(RenderCallback renderCallback, Tag[] tags) { public void renderNode(IRenderCallback renderCallback, Tag[] tags) {
// do nothing // do nothing
} }
@Override @Override
public void renderWay(RenderCallback renderCallback, Tag[] tags) { public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
renderCallback.renderWayText(mTextKey, mPaint, mStroke); renderCallback.renderWayText(mTextKey, mPaint, mStroke);
} }

View File

@ -14,7 +14,7 @@
*/ */
package org.mapsforge.android.rendertheme.renderinstruction; package org.mapsforge.android.rendertheme.renderinstruction;
import org.mapsforge.android.rendertheme.RenderCallback; import org.mapsforge.android.rendertheme.IRenderCallback;
import org.mapsforge.core.Tag; import org.mapsforge.core.Tag;
/** /**
@ -32,7 +32,7 @@ public interface RenderInstruction {
* @param tags * @param tags
* the tags of the node. * the tags of the node.
*/ */
void renderNode(RenderCallback renderCallback, Tag[] tags); void renderNode(IRenderCallback renderCallback, Tag[] tags);
/** /**
* @param renderCallback * @param renderCallback
@ -40,7 +40,7 @@ public interface RenderInstruction {
* @param tags * @param tags
* the tags of the way. * the tags of the way.
*/ */
void renderWay(RenderCallback renderCallback, Tag[] tags); void renderWay(IRenderCallback renderCallback, Tag[] tags);
/** /**
* Scales the stroke width of this RenderInstruction by the given factor. * Scales the stroke width of this RenderInstruction by the given factor.

View File

@ -16,7 +16,7 @@ package org.mapsforge.android.rendertheme.renderinstruction;
import java.io.IOException; import java.io.IOException;
import org.mapsforge.android.rendertheme.RenderCallback; import org.mapsforge.android.rendertheme.IRenderCallback;
import org.mapsforge.android.rendertheme.RenderThemeHandler; import org.mapsforge.android.rendertheme.RenderThemeHandler;
import org.mapsforge.core.Tag; import org.mapsforge.core.Tag;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
@ -74,12 +74,12 @@ public final class Symbol implements RenderInstruction {
} }
@Override @Override
public void renderNode(RenderCallback renderCallback, Tag[] tags) { public void renderNode(IRenderCallback renderCallback, Tag[] tags) {
renderCallback.renderPointOfInterestSymbol(mBitmap); renderCallback.renderPointOfInterestSymbol(mBitmap);
} }
@Override @Override
public void renderWay(RenderCallback renderCallback, Tag[] tags) { public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
renderCallback.renderAreaSymbol(mBitmap); renderCallback.renderAreaSymbol(mBitmap);
} }

View File

@ -22,10 +22,10 @@ import java.util.List;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import org.mapsforge.android.MapView; import org.mapsforge.android.MapView;
import org.mapsforge.android.mapgenerator.IMapGenerator;
import org.mapsforge.android.mapgenerator.JobTheme; import org.mapsforge.android.mapgenerator.JobTheme;
import org.mapsforge.android.mapgenerator.MapGenerator;
import org.mapsforge.android.mapgenerator.MapGeneratorJob; import org.mapsforge.android.mapgenerator.MapGeneratorJob;
import org.mapsforge.android.rendertheme.RenderCallback; import org.mapsforge.android.rendertheme.IRenderCallback;
import org.mapsforge.android.rendertheme.RenderTheme; import org.mapsforge.android.rendertheme.RenderTheme;
import org.mapsforge.android.rendertheme.RenderThemeHandler; import org.mapsforge.android.rendertheme.RenderThemeHandler;
import org.mapsforge.android.rendertheme.renderinstruction.Area; import org.mapsforge.android.rendertheme.renderinstruction.Area;
@ -48,11 +48,13 @@ import android.util.Log;
/** /**
* A DatabaseRenderer renders map tiles by reading from a {@link MapDatabase}. * A DatabaseRenderer renders map tiles by reading from a {@link MapDatabase}.
*/ */
public class DatabaseRenderer implements MapGenerator, RenderCallback, IMapDatabaseCallback { public class DatabaseRenderer implements IMapGenerator, IRenderCallback,
IMapDatabaseCallback {
private static String TAG = DatabaseRenderer.class.getName(); private static String TAG = DatabaseRenderer.class.getName();
private static final Byte DEFAULT_START_ZOOM_LEVEL = Byte.valueOf((byte) 12); private static final Byte DEFAULT_START_ZOOM_LEVEL = Byte.valueOf((byte) 12);
private static final byte LAYERS = 11; private static final byte LAYERS = 11;
private static final Paint PAINT_WATER_TILE_HIGHTLIGHT = new Paint(Paint.ANTI_ALIAS_FLAG); private static final Paint PAINT_WATER_TILE_HIGHTLIGHT = new Paint(
Paint.ANTI_ALIAS_FLAG);
private static final double STROKE_INCREASE = 1.5; private static final double STROKE_INCREASE = 1.5;
private static final byte STROKE_MIN_ZOOM_LEVEL = 12; private static final byte STROKE_MIN_ZOOM_LEVEL = 12;
@ -151,7 +153,8 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback, IMapDatab
PAINT_WATER_TILE_HIGHTLIGHT.setColor(Color.CYAN); PAINT_WATER_TILE_HIGHTLIGHT.setColor(Color.CYAN);
// mCoordinates = new float[1024]; // mCoordinates = new float[1024];
mTileBitmap = Bitmap.createBitmap(Tile.TILE_SIZE * 2, Tile.TILE_SIZE * 2, Bitmap.Config.RGB_565); mTileBitmap = Bitmap.createBitmap(Tile.TILE_SIZE * 2, Tile.TILE_SIZE * 2,
Bitmap.Config.RGB_565);
} }
@ -219,7 +222,8 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback, IMapDatab
} }
time_load = System.currentTimeMillis() - time_load; time_load = System.currentTimeMillis() - time_load;
mNodes = mLabelPlacement.placeLabels(mNodes, mPointSymbols, mAreaLabels, mCurrentTile); mNodes = mLabelPlacement.placeLabels(mNodes, mPointSymbols, mAreaLabels,
mCurrentTile);
long time_draw = System.currentTimeMillis(); long time_draw = System.currentTimeMillis();
@ -240,7 +244,8 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback, IMapDatab
} }
if (mapGeneratorJob.debugSettings.mDrawTileCoordinates) { if (mapGeneratorJob.debugSettings.mDrawTileCoordinates) {
mCanvasRasterer.drawTileCoordinates(mCurrentTile, time_load, time_draw, _nodes, _nodesDropped); mCanvasRasterer.drawTileCoordinates(mCurrentTile, time_load, time_draw,
_nodes, _nodesDropped);
} }
clearLists(); clearLists();
@ -282,7 +287,8 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback, IMapDatab
} }
@Override @Override
public void renderAreaCaption(String textKey, float verticalOffset, Paint paint, Paint stroke) { public void renderAreaCaption(String textKey, float verticalOffset, Paint paint,
Paint stroke) {
// mapDatabase.readTag(caption); // mapDatabase.readTag(caption);
// if (caption.value != null) { // if (caption.value != null) {
// float[] centerPosition = GeometryUtils // float[] centerPosition = GeometryUtils
@ -312,7 +318,8 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback, IMapDatab
} }
@Override @Override
public void renderPointOfInterestCaption(String textKey, float verticalOffset, Paint paint, Paint stroke) { public void renderPointOfInterestCaption(String textKey, float verticalOffset,
Paint paint, Paint stroke) {
// mapDatabase.readTag(caption); // mapDatabase.readTag(caption);
// if (caption.value != null) { // if (caption.value != null) {
// nodes.add(new PointTextContainer(caption.value, poiX, poiY + verticalOffset, paint, stroke)); // nodes.add(new PointTextContainer(caption.value, poiX, poiY + verticalOffset, paint, stroke));
@ -327,8 +334,9 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback, IMapDatab
@Override @Override
public void renderPointOfInterestSymbol(Bitmap symbol) { public void renderPointOfInterestSymbol(Bitmap symbol) {
mPointSymbols.add(new SymbolContainer(symbol, mPoiX - (symbol.getWidth() >> 1), mPoiY mPointSymbols.add(new SymbolContainer(symbol, mPoiX - (symbol.getWidth() >> 1),
- (symbol.getHeight() >> 1))); mPoiY
- (symbol.getHeight() >> 1)));
} }
@Override @Override
@ -359,7 +367,8 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback, IMapDatab
// private byte mPrevLayer = 0; // private byte mPrevLayer = 0;
@Override @Override
public void renderWay(byte layer, Tag[] tags, float[] wayNodes, int[] wayLengths, boolean changed) { public void renderWay(byte layer, Tag[] tags, float[] wayNodes, int[] wayLengths,
boolean changed) {
// if (mCoords == null) // if (mCoords == null)
// mCoords = mMapDatabase.getCoordinates(); // mCoords = mMapDatabase.getCoordinates();
@ -475,7 +484,8 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback, IMapDatab
@Override @Override
public void renderWay(Line line) { public void renderWay(Line line) {
List<ShapeContainer> c = mDrawingLayer.add(line.level, mWayDataContainer, line.paint); List<ShapeContainer> c = mDrawingLayer.add(line.level, mWayDataContainer,
line.paint);
if (mCurLevelContainer1 == null) if (mCurLevelContainer1 == null)
mCurLevelContainer1 = c; mCurLevelContainer1 = c;
@ -486,13 +496,16 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback, IMapDatab
@Override @Override
public void renderArea(Area area) { public void renderArea(Area area) {
if (area.paintFill != null) if (area.paintFill != null)
mCurLevelContainer1 = mDrawingLayer.add(area.level, mWayDataContainer, area.paintFill); mCurLevelContainer1 = mDrawingLayer.add(area.level, mWayDataContainer,
area.paintFill);
if (area.paintOutline != null) if (area.paintOutline != null)
mCurLevelContainer1 = mDrawingLayer.add(area.level, mWayDataContainer, area.paintOutline); mCurLevelContainer1 = mDrawingLayer.add(area.level, mWayDataContainer,
area.paintOutline);
} }
@Override @Override
public void renderWaySymbol(Bitmap symbolBitmap, boolean alignCenter, boolean repeatSymbol) { public void renderWaySymbol(Bitmap symbolBitmap, boolean alignCenter,
boolean repeatSymbol) {
// WayDecorator.renderSymbol(symbolBitmap, alignCenter, repeatSymbol, // WayDecorator.renderSymbol(symbolBitmap, alignCenter, repeatSymbol,
// coordinates, // coordinates,
// waySymbols); // waySymbols);
@ -508,11 +521,6 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback, IMapDatab
return mMapDatabase.readString(mWayDataContainer.textPos[0]); return mMapDatabase.readString(mWayDataContainer.textPos[0]);
} }
@Override
public boolean requiresInternetConnection() {
return false;
}
@Override @Override
public void setMapDatabase(IMapDatabase mapDatabase) { public void setMapDatabase(IMapDatabase mapDatabase) {
mMapDatabase = mapDatabase; mMapDatabase = mapDatabase;
@ -547,7 +555,8 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback, IMapDatab
private static float scaleLatitude(float latitude) { private static float scaleLatitude(float latitude) {
double sinLatitude = FloatMath.sin(latitude * PI180); double sinLatitude = FloatMath.sin(latitude * PI180);
return (float) (0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / PIx4) * mCurrentTileZoom return (float) (0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / PIx4)
* mCurrentTileZoom
- mCurrentTileY; - mCurrentTileY;
} }
@ -560,7 +569,8 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback, IMapDatab
*/ */
private static float scaleLongitude(float longitude) { private static float scaleLongitude(float longitude) {
return (float) ((longitude / 1000000.0 + 180) / 360 * mCurrentTileZoom) - mCurrentTileX; return (float) ((longitude / 1000000.0 + 180) / 360 * mCurrentTileZoom)
- mCurrentTileX;
} }
/** /**
@ -571,7 +581,8 @@ public class DatabaseRenderer implements MapGenerator, RenderCallback, IMapDatab
*/ */
private static void setScaleStrokeWidth(byte zoomLevel) { private static void setScaleStrokeWidth(byte zoomLevel) {
int zoomLevelDiff = Math.max(zoomLevel - STROKE_MIN_ZOOM_LEVEL, 0); int zoomLevelDiff = Math.max(zoomLevel - STROKE_MIN_ZOOM_LEVEL, 0);
DatabaseRenderer.renderTheme.scaleStrokeWidth((float) Math.pow(STROKE_INCREASE, zoomLevelDiff)); DatabaseRenderer.renderTheme.scaleStrokeWidth((float) Math.pow(STROKE_INCREASE,
zoomLevelDiff));
} }
@Override @Override

View File

@ -29,7 +29,7 @@ import javax.microedition.khronos.opengles.GL10;
import org.mapsforge.android.DebugSettings; import org.mapsforge.android.DebugSettings;
import org.mapsforge.android.MapView; import org.mapsforge.android.MapView;
import org.mapsforge.android.mapgenerator.JobParameters; import org.mapsforge.android.mapgenerator.JobParameters;
import org.mapsforge.android.mapgenerator.MapGenerator; import org.mapsforge.android.mapgenerator.IMapGenerator;
import org.mapsforge.android.mapgenerator.MapGeneratorJob; import org.mapsforge.android.mapgenerator.MapGeneratorJob;
import org.mapsforge.android.mapgenerator.MapWorker; import org.mapsforge.android.mapgenerator.MapWorker;
import org.mapsforge.android.mapgenerator.TileCacheKey; import org.mapsforge.android.mapgenerator.TileCacheKey;
@ -184,7 +184,7 @@ public class MapRenderer implements org.mapsforge.android.MapRenderer {
mJobList.clear(); mJobList.clear();
MapGenerator mapGenerator = mMapView.getMapGenerator(); IMapGenerator mapGenerator = mMapView.getMapGenerator();
int tiles = 0; int tiles = 0;
for (long tileY = tileTop - 1; tileY <= tileBottom + 1; tileY++) { for (long tileY = tileTop - 1; tileY <= tileBottom + 1; tileY++) {
for (long tileX = tileLeft - 1; tileX <= tileRight + 1; tileX++) { for (long tileX = tileLeft - 1; tileX <= tileRight + 1; tileX++) {

View File

@ -12,12 +12,11 @@
* You should have received a copy of the GNU Lesser General Public License along with * 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/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.mapsforge.tilemap; package org.mapsforge.app;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import android.content.res.Resources; import android.content.res.Resources;
import org.mapsforge.tilemap.R;
final class FileUtils { final class FileUtils {
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.00 "); private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.00 ");
@ -49,11 +48,14 @@ final class FileUtils {
return fileSize + " " + resources.getString(R.string.file_size_bytes); return fileSize + " " + resources.getString(R.string.file_size_bytes);
} else { } else {
if (fileSize < ONE_MEGABYTE) { if (fileSize < ONE_MEGABYTE) {
return DECIMAL_FORMAT.format(fileSize / ONE_KILOBYTE) + resources.getString(R.string.file_size_kb); return DECIMAL_FORMAT.format(fileSize / ONE_KILOBYTE)
+ resources.getString(R.string.file_size_kb);
} else if (fileSize < ONE_GIGABYTE) { } else if (fileSize < ONE_GIGABYTE) {
return DECIMAL_FORMAT.format(fileSize / ONE_MEGABYTE) + resources.getString(R.string.file_size_mb); return DECIMAL_FORMAT.format(fileSize / ONE_MEGABYTE)
+ resources.getString(R.string.file_size_mb);
} }
return DECIMAL_FORMAT.format(fileSize / ONE_GIGABYTE) + resources.getString(R.string.file_size_gb); return DECIMAL_FORMAT.format(fileSize / ONE_GIGABYTE)
+ resources.getString(R.string.file_size_gb);
} }
} }

View File

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

View File

@ -1,4 +1,4 @@
package org.mapsforge.tilemap; package org.mapsforge.app;
import java.io.FileFilter; import java.io.FileFilter;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -11,19 +11,19 @@ import org.mapsforge.android.MapController;
import org.mapsforge.android.MapView; import org.mapsforge.android.MapView;
import org.mapsforge.android.mapgenerator.MapDatabaseFactory; import org.mapsforge.android.mapgenerator.MapDatabaseFactory;
import org.mapsforge.android.mapgenerator.MapDatabaseInternal; import org.mapsforge.android.mapgenerator.MapDatabaseInternal;
import org.mapsforge.android.mapgenerator.MapGenerator;
import org.mapsforge.android.rendertheme.InternalRenderTheme; import org.mapsforge.android.rendertheme.InternalRenderTheme;
import org.mapsforge.android.utils.AndroidUtils; import org.mapsforge.android.utils.AndroidUtils;
import org.mapsforge.app.filefilter.FilterByFileExtension;
import org.mapsforge.app.filefilter.ValidMapFile;
import org.mapsforge.app.filefilter.ValidRenderTheme;
import org.mapsforge.app.filepicker.FilePicker;
import org.mapsforge.app.preferences.EditPreferences;
import org.mapsforge.core.BoundingBox; import org.mapsforge.core.BoundingBox;
import org.mapsforge.core.GeoPoint; import org.mapsforge.core.GeoPoint;
import org.mapsforge.database.IMapDatabase; import org.mapsforge.database.IMapDatabase;
import org.mapsforge.database.MapFileInfo; 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.annotation.TargetApi;
import android.app.ActionBar; import android.app.ActionBar;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
@ -175,13 +175,8 @@ public class TileMap extends MapActivity { // implements ActionBar.OnNavigationL
@Override @Override
public boolean onPrepareOptionsMenu(Menu menu) { public boolean onPrepareOptionsMenu(Menu menu) {
MapGenerator mapGenerator = mMapView.getMapGenerator();
// if (mapGenerator.requiresInternetConnection()) {
// menu.findItem(R.id.menu_info_map_file).setEnabled(false);
// } else {
// menu.findItem(R.id.menu_info_map_file).setEnabled(true); // menu.findItem(R.id.menu_info_map_file).setEnabled(true);
// }
if (isShowMyLocationEnabled()) { if (isShowMyLocationEnabled()) {
menu.findItem(R.id.menu_position_my_location_enable).setVisible(false); menu.findItem(R.id.menu_position_my_location_enable).setVisible(false);
@ -195,23 +190,9 @@ public class TileMap extends MapActivity { // implements ActionBar.OnNavigationL
menu.findItem(R.id.menu_position_my_location_disable).setEnabled(false); menu.findItem(R.id.menu_position_my_location_disable).setEnabled(false);
} }
if (mapGenerator.requiresInternetConnection()) { menu.findItem(R.id.menu_position_map_center).setEnabled(true);
menu.findItem(R.id.menu_position_map_center).setEnabled(false); menu.findItem(R.id.menu_render_theme).setEnabled(true);
} else { menu.findItem(R.id.menu_mapfile).setEnabled(true);
menu.findItem(R.id.menu_position_map_center).setEnabled(true);
}
if (mapGenerator.requiresInternetConnection()) {
menu.findItem(R.id.menu_render_theme).setEnabled(false);
} else {
menu.findItem(R.id.menu_render_theme).setEnabled(true);
}
if (mapGenerator.requiresInternetConnection()) {
menu.findItem(R.id.menu_mapfile).setEnabled(false);
} else {
menu.findItem(R.id.menu_mapfile).setEnabled(true);
}
return true; return true;
} }
@ -317,6 +298,7 @@ public class TileMap extends MapActivity { // implements ActionBar.OnNavigationL
} }
} }
@TargetApi(11)
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@ -332,12 +314,6 @@ public class TileMap extends MapActivity { // implements ActionBar.OnNavigationL
actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowTitleEnabled(false);
} }
// getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
// getActionBar().setBackgroundDrawable(
// getResources().getDrawable(R.drawable.action_bar));
// // getActionBar().setDisplayShowTitleEnabled(false);
// getActionBar().setIcon(R.drawable.bar_globe2);
// set up the layout views // set up the layout views
setContentView(R.layout.activity_advanced_map_viewer); setContentView(R.layout.activity_advanced_map_viewer);

View File

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

View File

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

View File

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

View File

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

View File

@ -12,15 +12,15 @@
* You should have received a copy of the GNU Lesser General Public License along with * 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/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.mapsforge.tilemap.filepicker; package org.mapsforge.app.filepicker;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import org.mapsforge.tilemap.R; import org.mapsforge.app.R;
import org.mapsforge.tilemap.filefilter.ValidFileFilter; import org.mapsforge.app.filefilter.ValidFileFilter;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;

View File

@ -12,11 +12,11 @@
* You should have received a copy of the GNU Lesser General Public License along with * 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/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.mapsforge.tilemap.filepicker; package org.mapsforge.app.filepicker;
import java.io.File; import java.io.File;
import org.mapsforge.tilemap.R; import org.mapsforge.app.R;
import android.content.Context; import android.content.Context;
import android.view.Gravity; import android.view.Gravity;
@ -79,14 +79,17 @@ class FilePickerIconAdapter extends BaseAdapter {
if (index == 0 && this.hasParentFolder) { if (index == 0 && this.hasParentFolder) {
// the parent directory of the current folder // the parent directory of the current folder
this.textView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.file_picker_back, 0, 0); this.textView.setCompoundDrawablesWithIntrinsicBounds(0,
R.drawable.file_picker_back, 0, 0);
this.textView.setText(".."); this.textView.setText("..");
} else { } else {
this.currentFile = this.files[index]; this.currentFile = this.files[index];
if (this.currentFile.isDirectory()) { if (this.currentFile.isDirectory()) {
this.textView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.file_picker_folder, 0, 0); this.textView.setCompoundDrawablesWithIntrinsicBounds(0,
R.drawable.file_picker_folder, 0, 0);
} else { } else {
this.textView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.file_picker_file, 0, 0); this.textView.setCompoundDrawablesWithIntrinsicBounds(0,
R.drawable.file_picker_file, 0, 0);
} }
this.textView.setText(this.currentFile.getName()); this.textView.setText(this.currentFile.getName());
} }

View File

@ -12,9 +12,9 @@
* You should have received a copy of the GNU Lesser General Public License along with * 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/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.mapsforge.tilemap.preferences; package org.mapsforge.app.preferences;
import org.mapsforge.tilemap.R; import org.mapsforge.app.R;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceActivity; import android.preference.PreferenceActivity;

View File

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

View File

@ -18,7 +18,7 @@ package org.mapsforge.core;
/** /**
* *
*/ */
public class SphericalMercator { public class WebMercator {
/** /**
* *
*/ */

View File

@ -0,0 +1,19 @@
/*
* Copyright 2010, 2011, 2012 mapsforge.org
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* 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.database;
public interface IMapTileData {
}

View File

@ -41,8 +41,8 @@ public class MapDatabase implements IMapDatabase {
private boolean mOpenFile = false; private boolean mOpenFile = false;
private static double radius = 6378137; // private static double radius = 6378137;
private static double D2R = Math.PI / 180; // private static double D2R = Math.PI / 180;
// private static double HALF_PI = Math.PI / 2; // private static double HALF_PI = Math.PI / 2;
@ -56,23 +56,49 @@ public class MapDatabase implements IMapDatabase {
// float lat1 = (float) MercatorProjection.pixelYToLatitude(cy - 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 lat2 = (float) MercatorProjection.pixelYToLatitude(cy + 100, tile.zoomLevel) * 1000000;
float lon1 = (float) MercatorProjection.pixelXToLongitude(cx - 100, tile.zoomLevel); float lon1 = (float) MercatorProjection.pixelXToLongitude(cx - 100,
float lon2 = (float) MercatorProjection.pixelXToLongitude(cx + 100, tile.zoomLevel); tile.zoomLevel);
float lat1 = (float) MercatorProjection.pixelYToLatitude(cy - 100, tile.zoomLevel); float lon2 = (float) MercatorProjection.pixelXToLongitude(cx + 100,
float lat2 = (float) MercatorProjection.pixelYToLatitude(cy + 100, tile.zoomLevel); 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 lonRadians = (D2R * lon1);
double latRadians = (D2R * lat1); // double latRadians = (D2R * lat1);
// spherical mercator projection // spherical mercator projection
lon1 = (float) (radius * lonRadians); // lon1 = (float) (radius * lonRadians);
lat1 = (float) (radius * Math.log(Math.tan(Math.PI * 0.25 + latRadians * 0.5))); // 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;
lonRadians = (D2R * lon2); lon1 = (float) MercatorProjection.pixelXToLongitude(cx - 80, tile.zoomLevel) * 1000000;
latRadians = (D2R * lat2); lon2 = (float) MercatorProjection.pixelXToLongitude(cx + 80, tile.zoomLevel) * 1000000;
lat1 = (float) MercatorProjection.pixelYToLatitude(cy - 80, tile.zoomLevel) * 1000000;
lon2 = (float) (radius * lonRadians); lat2 = (float) MercatorProjection.pixelYToLatitude(cy + 80, tile.zoomLevel) * 1000000;
lat2 = (float) (radius * Math.log(Math.tan(Math.PI * 0.25 + latRadians * 0.5)));
mCoords[0] = lon1; mCoords[0] = lon1;
mCoords[1] = lat1; mCoords[1] = lat1;
@ -91,28 +117,6 @@ public class MapDatabase implements IMapDatabase {
mIndex[0] = 10; mIndex[0] = 10;
// lon1 = (float) MercatorProjection.pixelXToLongitude(cx - 80, tile.zoomLevel) * 1000000;
// lon2 = (float) MercatorProjection.pixelXToLongitude(cx + 80, tile.zoomLevel) * 1000000;
// lat1 = (float) MercatorProjection.pixelYToLatitude(cy - 80, tile.zoomLevel) * 1000000;
// lat2 = (float) MercatorProjection.pixelYToLatitude(cy + 80, tile.zoomLevel) * 1000000;
//
// mCoords[10] = lon1;
// mCoords[11] = lat1;
//
// mCoords[12] = lon2;
// mCoords[13] = lat1;
//
// mCoords[14] = lon2;
// mCoords[15] = lat2;
//
// mCoords[16] = lon1;
// mCoords[17] = lat2;
//
// mCoords[18] = lon1;
// mCoords[19] = lat1;
//
// mIndex[1] = 10;
mapDatabaseCallback.renderWay((byte) 0, mTags, mCoords, mIndex, true); mapDatabaseCallback.renderWay((byte) 0, mTags, mCoords, mIndex, true);
} }

View File

@ -26,7 +26,7 @@ import java.util.Properties;
import org.mapsforge.core.BoundingBox; import org.mapsforge.core.BoundingBox;
import org.mapsforge.core.GeoPoint; import org.mapsforge.core.GeoPoint;
import org.mapsforge.core.SphericalMercator; import org.mapsforge.core.WebMercator;
import org.mapsforge.core.Tag; import org.mapsforge.core.Tag;
import org.mapsforge.core.Tile; import org.mapsforge.core.Tile;
import org.mapsforge.database.FileOpenResult; import org.mapsforge.database.FileOpenResult;
@ -54,7 +54,7 @@ public class MapDatabase implements IMapDatabase {
private final MapFileInfo mMapInfo = private final MapFileInfo mMapInfo =
new MapFileInfo(new BoundingBox(-180, -85, 180, 85), new MapFileInfo(new BoundingBox(-180, -85, 180, 85),
new Byte((byte) 14), new GeoPoint(53.11, 8.85), new Byte((byte) 14), new GeoPoint(53.11, 8.85),
SphericalMercator.NAME, WebMercator.NAME,
0, 0, 0, "de", "yo!", "hannes"); 0, 0, 0, "de", "yo!", "hannes");
// new MapFileInfo(new BoundingBox(-180, -90, 180, 90), // new MapFileInfo(new BoundingBox(-180, -90, 180, 90),
// new Byte((byte) 0), null, "Mercator", // new Byte((byte) 0), null, "Mercator",
@ -69,17 +69,12 @@ public class MapDatabase implements IMapDatabase {
private boolean connect() { private boolean connect() {
Connection conn = null; Connection conn = null;
// &socketTimeout=15&tcpKeepAlive=true
String dburl = "jdbc:postgresql://city.informatik.uni-bremen.de:5432/gis"; String dburl = "jdbc:postgresql://city.informatik.uni-bremen.de:5432/gis";
// String dburl = "jdbc:postgresql://city.informatik.uni-bremen.de:5432/planet-2.0";
// String dburl = "jdbc:postgresql://127.0.0.1:5432/bremen";
// String dburl = "jdbc:postgresql://127.0.0.1:5431/planet-2.0";
Properties dbOpts = new Properties(); Properties dbOpts = new Properties();
dbOpts.setProperty("user", "osm"); dbOpts.setProperty("user", "osm");
dbOpts.setProperty("password", "osm"); dbOpts.setProperty("password", "osm");
dbOpts.setProperty("socketTimeout", "30"); dbOpts.setProperty("socketTimeout", "50");
dbOpts.setProperty("tcpKeepAlive", "true"); dbOpts.setProperty("tcpKeepAlive", "true");
try { try {
@ -94,6 +89,8 @@ public class MapDatabase implements IMapDatabase {
pgconn.addDataType("hstore", PGHStore.class); pgconn.addDataType("hstore", PGHStore.class);
conn.createStatement().execute("set statement_timeout to 60000");
} catch (Exception e) { } catch (Exception e) {
System.err.println("Aborted due to error:"); System.err.println("Aborted due to error:");
e.printStackTrace(); e.printStackTrace();
@ -183,16 +180,8 @@ public class MapDatabase implements IMapDatabase {
} }
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
// try {
// connection.close();
// } catch (SQLException e1) {
// e1.printStackTrace();
// } finally {
connection = null; connection = null;
// }
} }
} }
@Override @Override
@ -327,6 +316,7 @@ public class MapDatabase implements IMapDatabase {
private void parseGeometryArray(ValueGetter data, int count) { private void parseGeometryArray(ValueGetter data, int count) {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
parseGeometry(data); parseGeometry(data);
mIndex[mIndexPos++] = 0;
} }
} }

View File

@ -0,0 +1,21 @@
/*
* Copyright 2010, 2011, 2012 mapsforge.org
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* 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.database.postgis;
import org.mapsforge.database.IMapTileData;
public class TileData implements IMapTileData {
}