diff --git a/DataExtractionOSM/src/com/osmand/ToDoConstants.java b/DataExtractionOSM/src/com/osmand/ToDoConstants.java index 9fcb45786e..443a1d2677 100644 --- a/DataExtractionOSM/src/com/osmand/ToDoConstants.java +++ b/DataExtractionOSM/src/com/osmand/ToDoConstants.java @@ -29,6 +29,7 @@ public class ToDoConstants { // IDEA TO HAVE : + // 66. Transport routing (show next stop, total distance, show stop get out). // 43. Enable poi filter by name // 58. Upload/Download zip-index from site & unzip them on phone // 45. Get clear settings. Move that setting on top settings screen. diff --git a/DataExtractionOSM/src/com/osmand/data/TransportStop.java b/DataExtractionOSM/src/com/osmand/data/TransportStop.java index 851752a910..ef49eb61b5 100644 --- a/DataExtractionOSM/src/com/osmand/data/TransportStop.java +++ b/DataExtractionOSM/src/com/osmand/data/TransportStop.java @@ -7,5 +7,8 @@ public class TransportStop extends MapObject { public TransportStop(Entity e){ super(e); } + + public TransportStop(){ + } } diff --git a/DataExtractionOSM/src/com/osmand/data/index/IndexBatchCreator.java b/DataExtractionOSM/src/com/osmand/data/index/IndexBatchCreator.java index 8d66a2bbbf..f8377c06b9 100644 --- a/DataExtractionOSM/src/com/osmand/data/index/IndexBatchCreator.java +++ b/DataExtractionOSM/src/com/osmand/data/index/IndexBatchCreator.java @@ -22,6 +22,7 @@ public class IndexBatchCreator { // config params private static final boolean indexPOI = true; private static final boolean indexAddress = false; + private static final boolean indexTransport = true; private static final boolean writeWayNodes = true; protected static final Log log = LogUtil.getLog(IndexBatchCreator.class); @@ -152,7 +153,7 @@ public class IndexBatchCreator { System.out.println("GENERATING INDEXES FINISHED "); } protected void generateIndex(File f){ - DataExtraction extr = new DataExtraction(indexAddress, indexPOI, false, true, false, false, indexDirFiles); + DataExtraction extr = new DataExtraction(indexAddress, indexPOI, indexTransport, indexAddress, false, false, indexDirFiles); try { Region country = extr.readCountry(f.getAbsolutePath(), new ConsoleProgressImplementation(9), null); DataIndexWriter dataIndexWriter = new DataIndexWriter(indexDirFiles, country); @@ -163,6 +164,9 @@ public class IndexBatchCreator { if(indexPOI){ dataIndexWriter.writePOI(name + "_" + IndexConstants.POI_TABLE_VERSION + IndexConstants.POI_INDEX_EXT, f.lastModified()); } + if(indexTransport){ + dataIndexWriter.writeTransport(name + "_" + IndexConstants.TRANSPORT_TABLE_VERSION + IndexConstants.TRANSPORT_INDEX_EXT, f.lastModified()); + } } catch (Exception e) { log.error("Exception generating indexes for " + f.getName()); //$NON-NLS-1$ } @@ -191,7 +195,10 @@ public class IndexBatchCreator { summary = "POI index for " + regionName + " " + descriptionFile; } else if(f.getName().endsWith(IndexConstants.ADDRESS_INDEX_EXT)){ String regionName = f.getName().substring(0, f.getName().length() - IndexConstants.ADDRESS_INDEX_EXT.length() - 2); - summary = "Adress index for " + regionName + " " + descriptionFile; + summary = "Adress index for " + regionName + " " + descriptionFile; + } else if(f.getName().endsWith(IndexConstants.TRANSPORT_INDEX_EXT)){ + String regionName = f.getName().substring(0, f.getName().length() - IndexConstants.TRANSPORT_INDEX_EXT.length() - 2); + summary = "Transport index for " + regionName + " " + descriptionFile; } else { continue; } diff --git a/OsmAnd/res/values-ru-rRU/strings.xml b/OsmAnd/res/values-ru-rRU/strings.xml index a7cda85d80..fac35b6b4d 100644 --- a/OsmAnd/res/values-ru-rRU/strings.xml +++ b/OsmAnd/res/values-ru-rRU/strings.xml @@ -1,5 +1,7 @@ + Показать остановки транспорта на карте + Показать транспорт Навигационное приложение OsmAnd Данные POI были успешно обновлены ({0} объектов загружено) Ошибка сохранения POI в локальный индекс diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index fabaa956c9..c9f632f366 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -1,5 +1,7 @@ + Show public transport stops on map + Show transport stops Navigation application OsmAnd POI data was updated successfully ({0} were loaded) Error updating local indexes diff --git a/OsmAnd/res/xml/settings_pref.xml b/OsmAnd/res/xml/settings_pref.xml index 004c59d803..df905f55fa 100644 --- a/OsmAnd/res/xml/settings_pref.xml +++ b/OsmAnd/res/xml/settings_pref.xml @@ -9,6 +9,7 @@ + diff --git a/OsmAnd/src/com/osmand/OsmandSettings.java b/OsmAnd/src/com/osmand/OsmandSettings.java index b9c12e6d95..1f6e87604b 100644 --- a/OsmAnd/src/com/osmand/OsmandSettings.java +++ b/OsmAnd/src/com/osmand/OsmandSettings.java @@ -63,6 +63,19 @@ public class OsmandSettings { SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE); return prefs.edit().putBoolean(SHOW_POI_OVER_MAP, val).commit(); } + + // this value string is synchronized with settings_pref.xml preference name + public static final String SHOW_TRANSPORT_OVER_MAP = "show_transport_over_map"; //$NON-NLS-1$ + + public static boolean isShowingTransportOverMap(Context ctx) { + SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE); + return prefs.getBoolean(SHOW_TRANSPORT_OVER_MAP, false); + } + + public static boolean setShowTransortOverMap(Context ctx, boolean val) { + SharedPreferences prefs = ctx.getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_WORLD_READABLE); + return prefs.edit().putBoolean(SHOW_TRANSPORT_OVER_MAP, val).commit(); + } // this value string is synchronized with settings_pref.xml preference name public static final String USER_NAME = "user_name"; //$NON-NLS-1$ diff --git a/OsmAnd/src/com/osmand/activities/MapActivity.java b/OsmAnd/src/com/osmand/activities/MapActivity.java index 9060fafbb1..0c8f06599a 100644 --- a/OsmAnd/src/com/osmand/activities/MapActivity.java +++ b/OsmAnd/src/com/osmand/activities/MapActivity.java @@ -174,9 +174,8 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat osmBugsLayer = new OsmBugsLayer(this); // 3. poi layer poiMapLayer = new POIMapLayer(); - // 4. poi layer + // 4. transport layer transportStopsLayer = new TransportStopsLayer(); - mapView.addLayer(transportStopsLayer); // 5. point navigation layer navigationLayer = new PointNavigationLayer(); mapView.addLayer(navigationLayer); @@ -353,7 +352,8 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat } private void updateSpeedBearing(Location location) { - // For gps it's bad way. It's widely used for testing purposes + // For network/gps it's bad way (not accurate). It's widely used for testing purposes + // possibly keep using only for emulator case if (!providerSupportsSpeed && locationLayer.getLastKnownLocation() != null && location != null) { if (locationLayer.getLastKnownLocation().distanceTo(location) > 3) { float d = location.distanceTo(locationLayer.getLastKnownLocation()); @@ -561,6 +561,13 @@ public class MapActivity extends Activity implements LocationListener, IMapLocat backToLocation.setVisibility(View.INVISIBLE); + if(mapView.getLayers().contains(transportStopsLayer) != OsmandSettings.isShowingTransportOverMap(this)){ + if(OsmandSettings.isShowingTransportOverMap(this)){ + mapView.addLayer(transportStopsLayer, routeLayer); + } else { + mapView.removeLayer(transportStopsLayer); + } + } if(mapView.getLayers().contains(poiMapLayer) != OsmandSettings.isShowingPoiOverMap(this)){ if(OsmandSettings.isShowingPoiOverMap(this)){ diff --git a/OsmAnd/src/com/osmand/activities/SettingsActivity.java b/OsmAnd/src/com/osmand/activities/SettingsActivity.java index 6aca2c3924..34c1c01f80 100644 --- a/OsmAnd/src/com/osmand/activities/SettingsActivity.java +++ b/OsmAnd/src/com/osmand/activities/SettingsActivity.java @@ -50,6 +50,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference private Preference downloadIndexes; private ListPreference routerPreference; private ListPreference maxLevelToDownload; + private CheckBoxPreference showTransport; @Override public void onCreate(Bundle savedInstanceState) { @@ -72,6 +73,8 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference autoZoom.setOnPreferenceChangeListener(this); showOsmBugs =(CheckBoxPreference) screen.findPreference(OsmandSettings.SHOW_OSM_BUGS); showOsmBugs.setOnPreferenceChangeListener(this); + showTransport =(CheckBoxPreference) screen.findPreference(OsmandSettings.SHOW_TRANSPORT_OVER_MAP); + showTransport.setOnPreferenceChangeListener(this); useEnglishNames =(CheckBoxPreference) screen.findPreference(OsmandSettings.USE_ENGLISH_NAMES); useEnglishNames.setOnPreferenceChangeListener(this); @@ -116,6 +119,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference rotateMapToBearing.setChecked(OsmandSettings.isRotateMapToBearing(this)); showViewAngle.setChecked(OsmandSettings.isShowingViewAngle(this)); showOsmBugs.setChecked(OsmandSettings.isShowingOsmBugs(this)); + showTransport.setChecked(OsmandSettings.isShowingTransportOverMap(this)); saveTrackToGpx.setChecked(OsmandSettings.isSavingTrackToGpx(this)); useEnglishNames.setChecked(OsmandSettings.usingEnglishNames(this)); autoZoom.setChecked(OsmandSettings.isAutoZoomEnabled(this)); @@ -201,6 +205,9 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference } else if(preference == autoZoom){ edit.putBoolean(OsmandSettings.AUTO_ZOOM_MAP, (Boolean) newValue); edit.commit(); + } else if(preference == showTransport){ + edit.putBoolean(OsmandSettings.SHOW_TRANSPORT_OVER_MAP, (Boolean) newValue); + edit.commit(); } else if(preference == showPoiOnMap){ edit.putBoolean(OsmandSettings.SHOW_POI_OVER_MAP, (Boolean) newValue); if((Boolean)newValue){