merge + added routepointslayer with implementation of populateObjectContextMenu

This commit is contained in:
unknown 2014-06-20 15:44:26 +03:00
commit a38063b77c
33 changed files with 531 additions and 195 deletions

21
AUTHORS
View file

@ -1,4 +1,17 @@
OsmAnd Copyright 2010-2014
Victor Shcherb - all parts of the project, originator
Alexey Pelykh - rendering and core parts
Hardy Mueller - main parts of the project, mostly rendering, UI interaction design
(C) OsmAnd 2010-2014
### Credits to all major contributors/developers :
* Victor Shcherb - all parts of the project, originator
* Pavol Zibrita - first contributor and developer of some utilities
* Dusan Kazik - one of the first contributors
* Andre Van Atten - project supporter, active forum participant, one of the first users.
* Dr. Hardy Mueller - map appearance concept and base renderers, international consistency and testing, usability, app scoping, concepts, documentation, wiki, market research.
* Yvecai - main contributor to Contour Lines and Hillshade maps
* Alexey Pelykh - C++ developer, created native library and made application much snappier.
* Max (Zahnstocher) - Java contributor, active forum participant.
* Harry van der Wolf - contributor (contribute to country boundaries + configuration file + address files and else), active forum participant.
* Robin `ypid` Schneider - opening hours contributor
### Other Pull requests
(C) All authors of translations and pull requests could be found in commits history :
- Translations are under special "contributor" name 'weblate'
- Pull requests have 2 committers, first is original contributor and second is project maintainer

View file

@ -1,3 +0,0 @@
(C) All authors of translations and pull requests could be found in commits history :
- Translations are under special "contributor" name 'weblate'
- Pull requests have 2 committers, first is original contributor and second is project maintainer

View file

@ -1,11 +0,0 @@
### Credits to all major contributors/developers :
* Victor Shcherb - all parts of the project, originator
* Pavol Zibrita - first contributor and developer of some utilities
* Dusan Kazik - one of the first contributors
* Andre Van Atten - project supporter, active forum participant, one of the first users.
* Dr. Hardy Mueller - map appearance concept and base renderers, international consistency and testing, usability, app scoping, concepts, documentation, wiki, market research.
* Yvecai - main contributor to Contour Lines and Hillshade maps
* Alexey Pelykh - C++ developer, created native library and made application much snappier.
* Max (Zahnstocher) - Java contributor, active forum participant.
* Harry van der Wolf - contributor (contribute to country boundaries + configuration file + address files and else), active forum participant.
* Robin `ypid` Schneider - opening hours contributor

92
LICENSE
View file

@ -1,6 +1,17 @@
OsmAnd - Android navigation software based on OSM maps.
Copyright (C) 2010-2014 OsmAnd Authors listed in AUTHORS file
OsmAnd - OSM Automated Navigation Directions - navigation software based on OSM maps.
Copyright (C) 2010-2014 OsmAnd ( Amstelveen, Netherlands - KvK 55730183).
The code in that repository is mainly covered by *GPLv3*, except some 3rd party libs and resources.
ATTENTION : please be aware that some art work has proprietary license.
Main AUTHORS (more detailed list in AUTHORS):
Victor Shcherb - all parts of the project, originator
Alexey Pelykh - rendering and core parts
Hardy Mueller - main parts of the project, mostly rendering, UI interaction design
Pavol Zibrita - first contributor and developer of some utilities
-------------------------- GPLv3 ----------------------------------
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
@ -13,8 +24,79 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-------------------------------------------------------------------
All graphical work, including UI design and graphical images,
is distributed under CC-BY-ND, unless it is mentionned with a spcial
license.
* Source code in main repositories is covered by GPLv3 (license exceptions below) :
- https://github.com/osmandapp/Osmand/tree/master/OsmAnd
- https://github.com/osmandapp/Osmand/tree/master/OsmAnd-java
- https://github.com/osmandapp/Osmand-core/tree/legacy_core
- https://github.com/osmandapp/OsmAnd-misc
- https://github.com/osmandapp/OsmAnd-tools
- https://github.com/osmandapp/OsmAnd-resources
* UI Design and UX work, such as layout, icons is covered by CC-BY-ND
- https://github.com/osmandapp/Osmand/tree/master/OsmAnd/res and others
* Map icons and their derived primities are covered by proprietary license :
- (C) icons8.com (https://github.com/osmandapp/OsmAnd-resources/tree/master/icons/svg/icons8)
* Generated voice files from TTS files are covered by proprietary license :
- Voice files (https://github.com/osmandapp/OsmAnd-resources/tree/master/voice)
* Fonts (https://github.com/osmandapp/OsmAnd-resources/tree/master/rendering_styles/fonts)
- Google Fonts (Apache License 2)
* Map icons (Mapnik) :
- Open-SVG-Map-Icons - Public Domain
* Non patched source libraries :
- SherlockBar - Apache Lisense - https://github.com/osmandapp/Osmand/tree/master/SherlockBar (https://github.com/JakeWharton/ActionBarSherlock/blob/master/LICENSE.txt)
* Patched libraries :
- Protobuf - New BSD License (patches - https://github.com/osmandapp/Osmand/tree/master/OsmAnd-java/protobuf-src, https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/protobuf)
- Expat - (https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/expat)
- Freetype - (https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/freetype)
- Giflib - (https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/giflib)
- Jpeg - (https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/jpeg)
- Libpng - (https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/libpng)
- Skia - (https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/skia)
- ZLib - (https://github.com/osmandapp/OsmAnd-core/tree/legacy_core/externals/zlib)
* 3rd party libraries present in the libs folder (https://github.com/osmandapp/Osmand/tree/master/OsmAnd-java/libs):
- bzip2-20090327.jar Bzip2 - Apache License
- bsh-core-2.0b4.jar Bean Shell - SPL and LGPL (http://www.beanshell.org/license.html)
- commons-logging-1.1.1.jar - Apache License
- gnu-trove-osmand.jar GNU trove - LGPL
- icu4j-49_1.jar - ICU license ( http://source.icu-project.org/repos/icu/icu/trunk/license.html)
- json-20090211.jar - BSD alike (http://www.json.org/license.html)
- junidecode-0.1.jar - BSD-4-Clause-UC (http://sourceforge.net/projects/junidecode/)
- kxml2-2.3.0.jar - BSD license ( http://www.kxml.org/)
- tuprolog.jar - LGPL (http://apice.unibo.it/xwiki/bin/view/Tuprolog/)
* Pull-requests and translations :
- All pull requests are accepted under MIT License (most honorable contributors are mentioned in AUTHORS list )
* Libraries not used in final product (https://github.com/osmandapp/OsmAnd-tools/tree/master/OsmAndMapCreator/libi)
- Ant libraries - (tools) https://github.com/osmandapp/Osmand/tree/master/OsmAnd/ant-lib
- jleveldb-v01.jar
- jsch-20120101.jar
- junit-4.10.jar
- mysql-connector-java-5.1.18-bin.jar
- sqlite-jdbc-3.7.6.3-20110609.081603-3.jar
- h2-latest.jar
* Special tools for new rendering (GPLv3) - (C) Alexey Pelykh
- https://github.com/osmandapp/OsmAnd-tools/tree/master/obf-inspector
- https://github.com/osmandapp/OsmAnd-tools/tree/master/obf-verifier
- https://github.com/osmandapp/OsmAnd-tools/tree/master/route-tester
* OSM data 2014
- Extracts - https://github.com/osmandapp/OsmAnd-misc/blob/master/osm-planet/osm-data/
* Data files
- Country boundaries - https://github.com/osmandapp/OsmAnd-misc/tree/master/osm-planet/geo-polygons (C) by Geofabrik - data free to use
- Country boundaries https://github.com/osmandapp/OsmAnd-misc/tree/master/osm-planet/gislab-polygons (C) by http://be.gis-lab.info - data free to use

View file

@ -63,8 +63,12 @@ public class RenderingContext {
return val * density;
}
public float getComplexValue(RenderingRuleSearchRequest req, RenderingRuleProperty prop, float defVal) {
return req.getFloatPropertyValue(prop, defVal) * density + req.getIntPropertyValue(prop, 0);
public float getComplexValue(RenderingRuleSearchRequest req, RenderingRuleProperty prop, int defVal) {
return req.getFloatPropertyValue(prop, 0) * density + req.getIntPropertyValue(prop, defVal);
}
public float getComplexValue(RenderingRuleSearchRequest req, RenderingRuleProperty prop) {
return req.getFloatPropertyValue(prop, 0) * density + req.getIntPropertyValue(prop, 0);
}
protected byte[] getIconRawData(String data) {

View file

@ -46,6 +46,7 @@ public class RenderingRuleStorageProperties {
public static final String TEXT_BOLD = "textBold";
public static final String TEXT_ORDER = "textOrder";
public static final String ICON_ORDER = "iconOrder";
public static final String ICON_VISIBLE_SIZE = "iconVisibleSize";
public static final String TEXT_MIN_DISTANCE = "textMinDistance";
public static final String TEXT_ON_PATH = "textOnPath";
public static final String ICON = "icon";
@ -109,6 +110,7 @@ public class RenderingRuleStorageProperties {
public RenderingRuleProperty R_TEXT_MIN_DISTANCE;
public RenderingRuleProperty R_TEXT_ON_PATH;
public RenderingRuleProperty R_ICON;
public RenderingRuleProperty R_ICON_VISIBLE_SIZE;
public RenderingRuleProperty R_LAYER;
public RenderingRuleProperty R_ORDER;
public RenderingRuleProperty R_POINT;
@ -134,6 +136,7 @@ public class RenderingRuleStorageProperties {
final List<RenderingRuleProperty> rules ;
final List<RenderingRuleProperty> customRules ;
public RenderingRuleStorageProperties() {
properties = new LinkedHashMap<String, RenderingRuleProperty>();
rules = new ArrayList<RenderingRuleProperty>();
@ -184,6 +187,7 @@ public class RenderingRuleStorageProperties {
R_TEXT_SIZE = registerRuleInternal(RenderingRuleProperty.createOutputFloatProperty(TEXT_SIZE));
R_TEXT_ORDER = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(TEXT_ORDER));
R_ICON_ORDER = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(ICON_ORDER));
R_ICON_VISIBLE_SIZE = registerRuleInternal(RenderingRuleProperty.createOutputFloatProperty(ICON_VISIBLE_SIZE));
R_TEXT_MIN_DISTANCE = registerRuleInternal(RenderingRuleProperty.createOutputFloatProperty(TEXT_MIN_DISTANCE));
R_TEXT_SHIELD = registerRuleInternal(RenderingRuleProperty.createOutputStringProperty(TEXT_SHIELD));

View file

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.osmand.plus" android:installLocation="auto" android:versionName="@string/app_version" android:versionCode="170">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto"
android:versionName="@string/app_version"
android:versionCode="170"
package="net.osmand.plus">
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="19"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

View file

@ -3,9 +3,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1"
android:background="?android:attr/activatedBackgroundIndicator">
android:orientation="horizontal">
<ImageView android:id="@+id/point_icon"
android:layout_width="32dp"
android:padding="3dp"

View file

@ -1528,7 +1528,7 @@ s často kladenými otázkami.</string>
<string name="osmo_expire_group">Vyprší za</string>
<string name="osmo_group_description">Popis</string>
<string name="osmo_group_policy">Politika</string>
<string name="osmo_connect_to_device_tracker_id">ID sledovaho zařízení</string>
<string name="osmo_connect_to_device_tracker_id">ID sledovaho zařízení</string>
<string name="osmo_connect_to_device_name">Jméno uživatele</string>
<string name="osmo_connect_to_group_id">ID skupiny</string>
<string name="osmo_group_name">Název skupiny</string>

View file

@ -28,7 +28,7 @@
<string name="live_monitoring">Tracking online in diretta</string>
<string name="live_monitoring_interval_descr">Specifica l\'intervallo del tracking in diretta</string>
<string name="live_monitoring_interval">Intervallo del Live tracking</string>
<string name="live_monitoring_url_descr">Specifica l\'indirizzo internet con la sintassi dei parametri: lat={0}, lon={1}, data/ora={2}, hdop={3}, altitudie={4}, velocità={5}, bearing={6}</string>
<string name="live_monitoring_url_descr">Specifica l\'indirizzo internet con la sintassi dei parametri: lat={0}, lon={1}, data/ora={2}, hdop={3}, altitudine={4}, velocità={5}, angolo={6}</string>
<string name="live_monitoring_url">Indirizzo internet per il tracking in diretta</string>
<string name="gpx_monitoring_disabled_warn">Abilita nelle impostazioni \'Registrazione della traccia nel file GPX\'.</string>
<string name="show_current_gpx_title">Visualizza la traccia corrente</string>
@ -1791,7 +1791,7 @@ Si consiglia di aggiungere uno o più punti intermedi per migliorarne le prestaz
<string name="osmo_connected_devices">Dispositivi collegati</string>
<string name="osmo_groups">Grupppi/Dispositivi OsMo</string>
<string name="osmo_groups">Gruppi/Dispositivi OsMo</string>
<string name="osmo_group_info">Informazioni</string>
<string name="osmo_group">Gruppo OsMo</string>
<string name="osmo_group_share">Per collegarsi al gruppo %2$s, specificare l\'id del gruppo (%1$s) o cliccare %3$s.</string>
@ -1802,7 +1802,7 @@ Si consiglia di aggiungere uno o più punti intermedi per migliorarne le prestaz
<string name="osmo_session_id_share">Url della sessione per tracciare il dispositivo (%1$s)</string>
<string name="osmo_tracker_id_share">Per collegarsi al dispositivo desiderato %2$s, cliccare sul link %3$ o specificarne l\'id di monitoraggio (%1$s)</string>
<string name="osmo_track_interval">Intervallo di registrazione</string>
<string name="osmo_track_interval_descr">Scegli l\'intervallo di tempo per l\'invio la posizione</string>
<string name="osmo_track_interval_descr">Scegli l\'intervallo di tempo per l\'invio della posizione</string>
<string name="int_days">giorni</string>
<string name="osmo_connect_menu">Connetti</string>
<string name="osmo_expire_group">Scade fra</string>

View file

@ -1583,8 +1583,7 @@ Afghanistan, Albanie, Algerije, Andorra, Angola, Anguilla, Antigua en Barbuda, A
</string>
<string name="base_world_map">Basis-wereldkaart</string>
<string name="map_magnifier">Kaartvergrootglas</string>
<string name="route_is_too_long">De route is mogelijk te lang om te worden berekend door de OsmAnd offline router.
De maximale afstand tussen start en bestemming is ongeveer 200 km. Maak één of meer routepunten om de route te berekenen.</string>
<string name="route_is_too_long">De bestemming ligt verder dan 200 kilometer. De routeberekening kan dan erg lang duren. Door zelf tussenliggende routepunten te maken kunt u de routeberekening sneller maken.</string>
<string name="auto_zoom_none">Geen automatische zoom</string>
<string name="auto_zoom_close">Zoom naar close-up</string>
<string name="auto_zoom_far">Zoom naar gemiddelde afstand</string>
@ -1631,7 +1630,7 @@ De maximale afstand tussen start en bestemming is ongeveer 200 km. Maak één of
<string name="routing_attr_prefer_motorway_name">Bij voorkeur autowegen</string>
<string name="routing_attr_prefer_motorway_description">Gebruik bij voorkeur autowegen</string>
<string name="routing_attr_short_way_name">Kortste route</string>
<string name="routing_attr_short_way_description">Gebruik de kortste route</string>
<string name="routing_attr_short_way_description">Kortste route gebruiken</string>
<string name="routing_attr_avoid_toll_name">Geen tolwegen</string>
<string name="routing_attr_avoid_toll_description">Vermijd tolwegen</string>
<string name="routing_attr_avoid_unpaved_name">Geen onverharde wegen</string>
@ -1862,4 +1861,6 @@ De maximale afstand tussen start en bestemming is ongeveer 200 km. Maak één of
<string name="selected">gekozen</string>
<string name="gpx_split_interval">Verdeel in stukken elke …</string>
<string name="gpx_info_waypoints">Routepunten: %1$s </string>
</resources>
<string name="show_zoom_buttons_navigation_descr">Zoomknoppen tonen tijdens navigeren</string>
<string name="show_zoom_buttons_navigation">Zoomknoppen</string>
</resources>

View file

@ -8,6 +8,8 @@
<string name="mark_as_visited">Mark as visited</string>
<string name="mark_as_not_visited">Mark as not-visited</string>
<string name="mark_as_current">Navigate to</string>
<string name="navigate_to_next">Navigate to next point</string>
<string name="map_widget_route_points">Route points</string>
<string name="route_points_activity">Route Points</string>
<string name="navigate_dialog">Navigate dialog</string>
</resources>

View file

@ -27,7 +27,6 @@ public class NameFinderPoiFilter extends PoiFilter {
List<Amenity> searchedAmenities = new ArrayList<Amenity>();
private String query = ""; //$NON-NLS-1$
private String lastError = ""; //$NON-NLS-1$
@ -55,12 +54,24 @@ public class NameFinderPoiFilter extends PoiFilter {
@Override
protected List<Amenity> searchAmenities(double lat, double lon, double topLatitude,
double bottomLatitude, double leftLongitude, double rightLongitude, ResultMatcher<Amenity> matcher) {
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
String NOMINATIM_API;
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {
NOMINATIM_API = "https://nominatim.openstreetmap.org/search/";
}
else {
NOMINATIM_API = "http://nominatim.openstreetmap.org/search/";
}
searchedAmenities.clear();
String viewbox = "viewboxlbrt="+((float) leftLongitude)+","+((float) bottomLatitude)+","+((float) rightLongitude)+","+((float) topLatitude);
try {
lastError = "";
String urlq = "http://nominatim.openstreetmap.org/search/"+URLEncoder.encode(query)+ "?format=xml&addressdetails=1&limit="+LIMIT+"&bounded=1&"+viewbox;
String urlq = NOMINATIM_API + URLEncoder.encode(query)+ "?format=xml&addressdetails=1&limit="+LIMIT+"&bounded=1&"+viewbox;
log.info(urlq);
URL url = new URL(urlq); //$NON-NLS-1$
InputStream stream = url.openStream();

View file

@ -121,6 +121,7 @@ public class OsmandApplication extends Application {
}
}
super.onCreate();
new Toast(this); // activate in UI thread to avoid further exceptions
appCustomization = new OsmAndAppCustomization();
appCustomization.setup(this);
@ -659,16 +660,31 @@ public class OsmandApplication extends Application {
return targetPointsHelper;
}
public void showShortToastMessage(int msgId, Object... args) {
AccessibleToast.makeText(this, getString(msgId, args), Toast.LENGTH_SHORT).show();
public void showShortToastMessage(final int msgId, final Object... args) {
uiHandler.post(new Runnable() {
@Override
public void run() {
AccessibleToast.makeText(OsmandApplication.this, getString(msgId, args), Toast.LENGTH_SHORT).show();
}
});
}
public void showToastMessage(int msgId, Object... args) {
AccessibleToast.makeText(this, getString(msgId, args), Toast.LENGTH_LONG).show();
public void showToastMessage(final int msgId, final Object... args) {
uiHandler.post(new Runnable() {
@Override
public void run() {
AccessibleToast.makeText(OsmandApplication.this, getString(msgId, args), Toast.LENGTH_LONG).show();
}
});
}
public void showToastMessage(String msg) {
AccessibleToast.makeText(this, msg, Toast.LENGTH_LONG).show();
public void showToastMessage(final String msg) {
uiHandler.post(new Runnable() {
@Override
public void run() {
AccessibleToast.makeText(OsmandApplication.this, msg, Toast.LENGTH_LONG).show();
}
});
}
public SQLiteAPI getSQLiteAPI() {

View file

@ -86,6 +86,7 @@ public abstract class OsmandPlugin {
if(Version.isRouteNavPluginInlined(app)) {
RoutePointsPlugin routePointsPlugin = new RoutePointsPlugin(app);
installedPlugins.add(routePointsPlugin);
enablePlugin(app, routePointsPlugin, true);
}
installPlugin(OSMODROID_PLUGIN_COMPONENT, OsMoDroidPlugin.ID, app, new OsMoDroidPlugin(app));
@ -137,7 +138,7 @@ public abstract class OsmandPlugin {
public void mapActivityDestroy(MapActivity activity) { }
public void destinationReached() { }
public boolean destinationReached() { return true; }
public void settingsActivityCreate(SettingsActivity activity, PreferenceScreen screen) {}
@ -240,10 +241,14 @@ public abstract class OsmandPlugin {
}
}
public static void onDestinationReached() {
public static boolean onDestinationReached() {
boolean b = true;
for (OsmandPlugin plugin : activePlugins) {
plugin.destinationReached();
if(!plugin.destinationReached()){
b = false;
}
}
return b;
}

View file

@ -754,7 +754,15 @@ public class OsmandSettings {
AUTO_ZOOM_MAP.setModeDefaultValue(ApplicationMode.PEDESTRIAN, AutoZoomMap.NONE);
}
public final CommonPreference<Integer> DELAY_TO_START_NAVIGATION = new IntPreference("delay_to_start_navigation", 10).makeGlobal().cache();
public final CommonPreference<Integer> DELAY_TO_START_NAVIGATION = new IntPreference("delay_to_start_navigation", -1) {
protected Integer getDefaultValue() {
if(DEFAULT_APPLICATION_MODE.get().isDerivedRoutingFrom(ApplicationMode.CAR)) {
return 10;
}
return -1;
};
}.makeGlobal().cache();
public final CommonPreference<Boolean> SNAP_TO_ROAD = new BooleanPreference("snap_to_road", false).makeProfile().cache();
{

View file

@ -284,7 +284,7 @@ public class MapActivityLayers {
adapter.item(R.string.layer_favorites).selected(settings.SHOW_FAVORITES.get() ? 1 : 0)
.icons(R.drawable.ic_action_fav_dark, R.drawable.ic_action_fav_light).reg();
adapter.item(R.string.layer_gpx_layer).selected(
getApplication().getSelectedGpxHelper() != null ? 1 : 0)
getApplication().getSelectedGpxHelper().isShowingAnyGpxFiles()? 1 : 0)
// .icons(R.drawable.ic_action_foot_dark, R.drawable.ic_action_foot_light)
.icons(R.drawable.ic_action_polygom_dark, R.drawable.ic_action_polygom_light)
.reg();

View file

@ -142,6 +142,7 @@ public class SearchAddressOnlineFragment extends SherlockFragment implements Sea
}
protected void searchPlaces(final String search) {
if(Algorithms.isEmpty(search)){
return;
}
@ -154,9 +155,21 @@ public class SearchAddressOnlineFragment extends SherlockFragment implements Sea
@Override
protected Void doInBackground(Void... params) {
try {
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
String NOMINATIM_API;
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {
NOMINATIM_API = "https://nominatim.openstreetmap.org/search";
}
else {
NOMINATIM_API = "http://nominatim.openstreetmap.org/search";
}
final List<Place> places = new ArrayList<Place>();
StringBuilder b = new StringBuilder();
b.append("http://nominatim.openstreetmap.org/search"); //$NON-NLS-1$
b.append(NOMINATIM_API); //$NON-NLS-1$
b.append("?format=xml&addressdetails=0&accept-language=").append(Locale.getDefault().getLanguage()); //$NON-NLS-1$
b.append("&q=").append(URLEncoder.encode(search, "UTF-8")); //$NON-NLS-1$

View file

@ -331,7 +331,7 @@ public class EditingPOIActivity implements DialogProvider {
@Override
public void onClick(View v) {
ctx.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://wiki.openstreetmap.org/wiki/Map_Features")));
ctx.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://wiki.openstreetmap.org/wiki/Map_Features")));
}
});
linkToOsmDoc.setMovementMethod(LinkMovementMethod.getInstance());

View file

@ -44,9 +44,6 @@ import android.view.View;
import android.widget.Toast;
public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
// private final static String SITE_API = "http://api06.dev.openstreetmap.org/";
private final static String SITE_API = "http://api.openstreetmap.org/"; //$NON-NLS-1$
private static final long NO_CHANGESET_ID = -1;
@ -73,7 +70,25 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
return entityInfo;
}
private final static String URL_TO_UPLOAD_GPX = " http://api.openstreetmap.org/api/0.6/gpx/create";
private static String getSiteApi()
{
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
String RETURN_API;
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {
RETURN_API = "https://api.openstreetmap.org/";
}
else {
RETURN_API = "http://api.openstreetmap.org/";
}
// RETURN_API = "http://api06.dev.openstreetmap.org/";
return RETURN_API;
}
private final static String URL_TO_UPLOAD_GPX = getSiteApi() + "api/0.6/gpx/create";
public String uploadGPXFile(String tagstring, String description, String visibility, File f) {
String url = URL_TO_UPLOAD_GPX;
@ -178,7 +193,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
} catch (IOException e) {
log.error("Unhandled exception", e); //$NON-NLS-1$
}
String response = sendRequest(SITE_API + "api/0.6/changeset/create/", "PUT", writer.getBuffer().toString(), ctx.getString(R.string.opening_changeset), true); //$NON-NLS-1$ //$NON-NLS-2$
String response = sendRequest(getSiteApi() + "api/0.6/changeset/create/", "PUT", writer.getBuffer().toString(), ctx.getString(R.string.opening_changeset), true); //$NON-NLS-1$ //$NON-NLS-2$
if (response != null && response.length() > 0) {
id = Long.parseLong(response);
}
@ -256,7 +271,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
} catch (IOException e) {
log.error("Unhandled exception", e); //$NON-NLS-1$
}
String res = sendRequest(SITE_API+"api/0.6/changeset/"+changeSetId + "/upload", "POST", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String res = sendRequest(getSiteApi() + "api/0.6/changeset/"+changeSetId + "/upload", "POST", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
writer.getBuffer().toString(), ctx.getString(R.string.commiting_node), true);
log.debug(res+""); //$NON-NLS-1$
if (res != null) {
@ -286,7 +301,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
@Override
public void closeChangeSet() {
if (changeSetId != NO_CHANGESET_ID) {
String response = sendRequest(SITE_API+"api/0.6/changeset/"+changeSetId+"/close", "PUT", "", ctx.getString(R.string.closing_changeset), true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
String response = sendRequest(getSiteApi() + "api/0.6/changeset/"+changeSetId+"/close", "PUT", "", ctx.getString(R.string.closing_changeset), true); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
log.info("Response : " + response); //$NON-NLS-1$
changeSetId = NO_CHANGESET_ID;
}
@ -296,7 +311,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
public EntityInfo loadNode(Node n) {
long nodeId = n.getId(); // >> 1;
try {
String res = sendRequest(SITE_API + "api/0.6/node/"+nodeId, "GET", null, ctx.getString(R.string.loading_poi_obj) + nodeId, false); //$NON-NLS-1$ //$NON-NLS-2$
String res = sendRequest(getSiteApi() + "api/0.6/node/"+nodeId, "GET", null, ctx.getString(R.string.loading_poi_obj) + nodeId, false); //$NON-NLS-1$ //$NON-NLS-2$
if(res != null){
OsmBaseStorage st = new OsmBaseStorage();
st.parseOSM(new ByteArrayInputStream(res.getBytes("UTF-8")), null, null, true); //$NON-NLS-1$
@ -330,7 +345,7 @@ public class OpenstreetmapRemoteUtil implements OpenstreetmapUtil {
}
long nodeId = n.getId() >> 1;
try {
String res = sendRequest(SITE_API+"api/0.6/node/"+nodeId, "GET", null, ctx.getString(R.string.loading_poi_obj) + nodeId, false); //$NON-NLS-1$ //$NON-NLS-2$
String res = sendRequest(getSiteApi() + "api/0.6/node/"+nodeId, "GET", null, ctx.getString(R.string.loading_poi_obj) + nodeId, false); //$NON-NLS-1$ //$NON-NLS-2$
if(res != null){
OsmBaseStorage st = new OsmBaseStorage();
st.parseOSM(new ByteArrayInputStream(res.getBytes("UTF-8")), null, null, true); //$NON-NLS-1$

View file

@ -235,9 +235,20 @@ public class OsmBugsLayer extends OsmandMapLayer implements IContextMenuProvider
protected List<OpenStreetNote> loadingBugs(double topLatitude, double leftLongitude, double bottomLatitude,double rightLongitude){
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
String SITE_API;
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {
SITE_API = "https://api.openstreetmap.org/";
}
else {
SITE_API = "http://api.openstreetmap.org/";
}
List<OpenStreetNote> bugs = new ArrayList<OpenStreetNote>();
StringBuilder b = new StringBuilder();
b.append("http://api.openstreetmap.org/api/0.6/notes?bbox="); //$NON-NLS-1$
b.append(SITE_API + "api/0.6/notes?bbox="); //$NON-NLS-1$
b.append(leftLongitude); //$NON-NLS-1$
b.append(",").append(bottomLatitude); //$NON-NLS-1$
b.append(",").append(rightLongitude); //$NON-NLS-1$

View file

@ -21,8 +21,22 @@ import org.apache.commons.logging.Log;
public class OsmBugsRemoteUtil implements OsmBugsUtil {
private static final Log log = PlatformUtil.getLog(OsmBugsRemoteUtil.class);
private final static String SITE_API = "http://api.openstreetmap.org/api/0.6/notes"; //$NON-NLS-1$
static String getNotesApi()
{
final int deviceApiVersion = android.os.Build.VERSION.SDK_INT;
String RETURN_API;
if (deviceApiVersion >= android.os.Build.VERSION_CODES.GINGERBREAD) {
RETURN_API = "https://api.openstreetmap.org/api/0.6/notes";
}
else {
RETURN_API = "http://api.openstreetmap.org/api/0.6/notes";
}
return RETURN_API;
}
private OsmandApplication app;
private OsmandSettings settings;
@ -35,7 +49,7 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
@Override
public String createNewBug(double latitude, double longitude, String text){
StringBuilder b = new StringBuilder();
b.append(SITE_API).append("?"); //$NON-NLS-1$
b.append(getNotesApi()).append("?"); //$NON-NLS-1$
b.append("lat=").append(latitude); //$NON-NLS-1$
b.append("&lon=").append(longitude); //$NON-NLS-1$
b.append("&text=").append(URLEncoder.encode(text)); //$NON-NLS-1$
@ -45,7 +59,7 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
@Override
public String addingComment(long id, String text){
StringBuilder b = new StringBuilder();
b.append(SITE_API).append("/");
b.append(getNotesApi()).append("/");
b.append(id); //$NON-NLS-1$
b.append("/comment?text=").append(URLEncoder.encode(text)); //$NON-NLS-1$
return editingPOI(b.toString(), "POST", "adding comment"); //$NON-NLS-1$
@ -54,7 +68,7 @@ public class OsmBugsRemoteUtil implements OsmBugsUtil {
@Override
public String closingBug(long id, String text){
StringBuilder b = new StringBuilder();
b.append(SITE_API).append("/");
b.append(getNotesApi()).append("/");
b.append(id); //$NON-NLS-1$
b.append("/close?text=").append(URLEncoder.encode(text)); //$NON-NLS-1$
return editingPOI(b.toString(), "POST", "close bug") ; //$NON-NLS-1$

View file

@ -4,7 +4,6 @@ import gnu.trove.list.array.TIntArrayList;
import gnu.trove.map.hash.TIntObjectHashMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashMap;
@ -86,6 +85,7 @@ public class OsmandRenderer {
float y = 0;
String resId;
int iconOrder;
float iconSize;
}
@ -315,29 +315,34 @@ public class OsmandRenderer {
Bitmap ico = RenderingIcons.getIcon(context, icon.resId);
if (ico != null) {
if (icon.y >= 0 && icon.y < rc.height && icon.x >= 0 && icon.x < rc.width) {
float left = icon.x - ico.getWidth() / 2 * rc.screenDensityRatio;
float top = icon.y - ico.getHeight() / 2 * rc.screenDensityRatio;
float right = left + ico.getWidth() * rc.screenDensityRatio;
float bottom = top + ico.getHeight() * rc.screenDensityRatio;
RectF rf = new RectF(left, top, right , bottom);
boundIntersections.queryInBox(new QuadRect(left, top, right, bottom), result);
int visbleWidth = icon.iconSize >= 0 ? (int) icon.iconSize : ico.getWidth();
int visbleHeight = icon.iconSize >= 0 ? (int) icon.iconSize : ico.getHeight();
boolean intersects = false;
for(RectF r : result) {
if(r.intersect(rf)) {
intersects = true;
break;
RectF rf = calculateRect(rc, icon, ico.getWidth(), ico.getHeight());
RectF visibleRect = null;
if (visbleHeight > 0 && visbleWidth > 0) {
visibleRect = calculateRect(rc, icon, visbleWidth, visbleHeight);
boundIntersections.queryInBox(new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom), result);
for (RectF r : result) {
if (r.intersect(visibleRect)) {
intersects = true;
break;
}
}
}
if (!intersects) {
if(rc.screenDensityRatio != 1f){
Rect src = new Rect(0, 0, ico.getWidth(), ico
.getHeight());
if (rc.screenDensityRatio != 1f) {
Rect src = new Rect(0, 0, ico.getWidth(), ico.getHeight());
cv.drawBitmap(ico, src, rf, paintIcon);
} else {
cv.drawBitmap(ico, left, top, paintIcon);
cv.drawBitmap(ico, rf.left, rf.top, paintIcon);
}
if(visibleRect != null) {
visibleRect.inset(-visibleRect.width() / 4, -visibleRect.height() / 4);
boundIntersections.insert(visibleRect,
new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom));
}
rf.inset(-rf.width()/4, -rf.height()/4);
boundIntersections.insert(rf, new QuadRect(rf.left, rf.top, rf.right, rf.bottom));
}
}
}
@ -347,6 +352,16 @@ public class OsmandRenderer {
}
}
}
private RectF calculateRect(RenderingContext rc, IconDrawInfo icon, int visbleWidth, int visbleHeight) {
RectF rf;
float left = icon.x - visbleWidth / 2 * rc.screenDensityRatio;
float top = icon.y - visbleHeight / 2 * rc.screenDensityRatio;
float right = left + visbleWidth * rc.screenDensityRatio;
float bottom = top + visbleHeight * rc.screenDensityRatio;
rf = new RectF(left, top, right, bottom);
return rf;
}
Comparator<MapDataObjectPrimitive> sortByOrder() {
return new Comparator<MapDataObjectPrimitive>() {
@ -649,7 +664,7 @@ public class OsmandRenderer {
p.setColorFilter(null);
p.clearShadowLayer();
p.setStyle(Style.STROKE);
p.setStrokeWidth(rc.getComplexValue(req, rStrokeW, 0));
p.setStrokeWidth(rc.getComplexValue(req, rStrokeW));
String cap = req.getStringPropertyValue(rCap);
if(!Algorithms.isEmpty(cap)){
p.setStrokeCap(Cap.valueOf(cap.toUpperCase()));
@ -700,7 +715,7 @@ public class OsmandRenderer {
if(shadowColor == 0) {
shadowColor = rc.shadowRenderingColor;
}
int shadowRadius = (int) rc.getComplexValue(req, req.ALL.R_SHADOW_RADIUS, 0);
int shadowRadius = (int) rc.getComplexValue(req, req.ALL.R_SHADOW_RADIUS);
if (shadowColor == 0) {
shadowRadius = 0;
}
@ -742,6 +757,7 @@ public class OsmandRenderer {
ico.x = ps.x;
ico.y = ps.y;
ico.iconOrder = render.getIntPropertyValue(render.ALL.R_ICON_ORDER, 100);
ico.iconSize = rc.getComplexValue(render, render.ALL.R_ICON_VISIBLE_SIZE, -1);
ico.resId = resId;
rc.iconsToDraw.add(ico);
}
@ -853,7 +869,7 @@ public class OsmandRenderer {
if (path != null) {
if(drawOnlyShadow) {
int shadowColor = render.getIntPropertyValue(render.ALL.R_SHADOW_COLOR);
int shadowRadius = (int) rc.getComplexValue(render, render.ALL.R_SHADOW_RADIUS, 0);
int shadowRadius = (int) rc.getComplexValue(render, render.ALL.R_SHADOW_RADIUS);
if(shadowColor == 0) {
shadowColor = rc.shadowRenderingColor;
}

View file

@ -63,21 +63,21 @@ public class TextRenderer {
public void fillProperties(RenderingContext rc, RenderingRuleSearchRequest render, float centerX, float centerY) {
this.centerX = centerX;
// used only for draw on path where centerY doesn't play role
this.vOffset = (int) rc.getComplexValue(render, render.ALL.R_TEXT_DY, 0);
this.vOffset = (int) rc.getComplexValue(render, render.ALL.R_TEXT_DY);
this.centerY = centerY + this.vOffset;
textColor = render.getIntPropertyValue(render.ALL.R_TEXT_COLOR);
if (textColor == 0) {
textColor = Color.BLACK;
}
textSize = rc.getComplexValue(render, render.ALL.R_TEXT_SIZE, 0);
textShadow = (int) rc.getComplexValue(render, render.ALL.R_TEXT_HALO_RADIUS, 0);
textSize = rc.getComplexValue(render, render.ALL.R_TEXT_SIZE);
textShadow = (int) rc.getComplexValue(render, render.ALL.R_TEXT_HALO_RADIUS);
textShadowColor = render.getIntPropertyValue(render.ALL.R_TEXT_HALO_COLOR);
if(textShadowColor == 0) {
textShadowColor = Color.WHITE;
}
textWrap = (int) rc.getComplexValue(render, render.ALL.R_TEXT_WRAP_WIDTH, 0);
textWrap = (int) rc.getComplexValue(render, render.ALL.R_TEXT_WRAP_WIDTH);
bold = render.getIntPropertyValue(render.ALL.R_TEXT_BOLD, 0) > 0;
minDistance = rc.getComplexValue(render, render.ALL.R_TEXT_MIN_DISTANCE, 0);
minDistance = rc.getComplexValue(render, render.ALL.R_TEXT_MIN_DISTANCE);
if (render.isSpecified(render.ALL.R_TEXT_SHIELD)) {
shieldRes = render.getStringPropertyValue(render.ALL.R_TEXT_SHIELD);
}

View file

@ -10,6 +10,7 @@ import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandListActivity;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.routepointsnavigation.RoutePointsPlugin.RoutePoint;
@ -45,7 +46,6 @@ public class RoutePointsActivity extends OsmandListActivity {
protected static final int MARK_AS_CURRENT_ID = 6;
protected static final int AS_VISITED_ID = 7;
protected static final int POI_ON_MAP_ID = 8;
protected static final int GPX_SELECT_ID = 9;
private RoutePointsPlugin plugin;
private OsmandApplication app;
@ -59,7 +59,7 @@ public class RoutePointsActivity extends OsmandListActivity {
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
super.onCreate(savedInstanceState);
setSupportProgressBarIndeterminateVisibility(false);
getSupportActionBar().setTitle(R.string.route_points_activity);
super.setContentView(R.layout.route_steps_main);
if (plugin.getCurrentRoute() == null) {
selectGPX();
@ -78,7 +78,8 @@ public class RoutePointsActivity extends OsmandListActivity {
app.getSelectedGpxHelper().setGpxFileToDisplay(gpx);
plugin.setCurrentRoute(gpx);
SelectedRouteGpxFile sgpx = plugin.getCurrentRoute();
if (!sgpx.getCurrentPoints().get(0).isNextNavigate){
if (!sgpx.getCurrentPoints().isEmpty() &&
!sgpx.getCurrentPoints().get(0).isNextNavigate){
sgpx.naviateToNextPoint();
}
prepareView();
@ -110,7 +111,7 @@ public class RoutePointsActivity extends OsmandListActivity {
@Override
public void onClick(View widget) {
getSherlock().startActionMode(mGpxActionModeCallback);
selectGPX();
}
}, 0, content.length(), 0);
gpxName.setText(content);
@ -216,33 +217,7 @@ public class RoutePointsActivity extends OsmandListActivity {
}.execute(plugin.getCurrentRoute());
}
private ActionMode.Callback mGpxActionModeCallback = new ActionMode.Callback() {
@Override
public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
createMenuItem(menu, GPX_SELECT_ID, R.string.select_gpx, R.drawable.ic_action_layers_light, R.drawable.ic_action_layers_dark,
MenuItem.SHOW_AS_ACTION_IF_ROOM);
return true;
}
@Override
public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
return false;
}
@Override
public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
if (menuItem.getItemId() == GPX_SELECT_ID) {
selectGPX();
}
actionMode.finish();
return true;
}
@Override
public void onDestroyActionMode(ActionMode actionMode) {
adapter.notifyDataSetChanged();
}
};
private ActionMode.Callback getPointActionModeCallback(final RoutePoint rp) {
return new ActionMode.Callback() {
@ -311,6 +286,7 @@ public class RoutePointsActivity extends OsmandListActivity {
return true;
} else if (item.getItemId() == NAVIGATE_DIALOG_ID){
app.getSettings().navigateDialog();
MapActivity.launchMapActivityMoveToTop(getMyApplication());
return true;
}
return super.onOptionsItemSelected(item);

View file

@ -0,0 +1,106 @@
package net.osmand.plus.routepointsnavigation;
import android.content.DialogInterface;
import android.graphics.Canvas;
import android.graphics.PointF;
import net.osmand.data.LatLon;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.views.ContextMenuLayer;
import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.OsmandMapTileView;
import java.util.List;
/**
* Created by Barsik on 20.06.2014.
*/
public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
private final RoutePointsPlugin plugin;
private final MapActivity map;
public RoutePointsLayer(MapActivity map, RoutePointsPlugin plugin){
this.map = map;
this.plugin = plugin;
}
@Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> o) {
}
@Override
public LatLon getObjectLocation(Object o) {
return null;
}
@Override
public String getObjectDescription(Object o) {
return null;
}
@Override
public String getObjectName(Object o) {
return null;
}
@Override
public void initLayer(OsmandMapTileView view) {
}
@Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
}
@Override
public void destroyLayer() {
}
@Override
public boolean drawInScreenPixels() {
return false;
}
@Override
public void populateObjectContextMenu(Object o, ContextMenuAdapter adapter) {
if (o instanceof GPXUtilities.WptPt && plugin.getCurrentRoute() != null){
final GPXUtilities.WptPt point = (GPXUtilities.WptPt) o;
ContextMenuAdapter.OnContextMenuClick listener = new ContextMenuAdapter.OnContextMenuClick() {
@Override
public void onContextMenuClick(int itemId, int pos, boolean isChecked, DialogInterface dialog) {
if (itemId == R.string.mark_as_not_visited){
plugin.getCurrentRoute().markPoint(point,false);
} else if (itemId == R.string.mark_as_visited) {
plugin.getCurrentRoute().markPoint(point, true);
} else if (itemId == R.string.mark_as_current){
plugin.getCurrentRoute().navigateToPoint(point);
}
}
};
if (plugin.getCurrentRoute().getPointStatus(point)){
adapter.item(R.string.mark_as_not_visited).icons(
R.drawable.ic_action_ok_dark, R.drawable.ic_action_ok_light).listen(listener).reg();
} else {
adapter.item(R.string.mark_as_visited).icons(
R.drawable.ic_action_gremove_dark, R.drawable.ic_action_gremove_light).listen(listener).reg();
}
RoutePointsPlugin.RoutePoint routePoint = plugin.getCurrentRoute().getRoutePointFromWpt(point);
if (routePoint.isNextNavigate) {
adapter.item(R.string.navigate_to_next).icons(
R.drawable.ic_action_gnext_dark, R.drawable.ic_action_gnext_light).listen(listener).reg();
} else {
adapter.item(R.string.mark_as_current).icons(
R.drawable.ic_action_signpost_dark, R.drawable.ic_action_signpost_light).listen(listener).reg();
}
}
}
}

View file

@ -41,7 +41,9 @@ public class RoutePointsPlugin extends OsmandPlugin {
private OsmandApplication app;
private TextInfoWidget routeStepsControl;
private SelectedRouteGpxFile currentRoute;
private RoutePointsLayer routePointsLayer;
public RoutePointsPlugin(OsmandApplication app) {
ApplicationMode.regWidget("route_steps", ApplicationMode.CAR, ApplicationMode.DEFAULT);
this.app = app;
@ -51,21 +53,25 @@ public class RoutePointsPlugin extends OsmandPlugin {
return currentRoute;
}
public void setCurrentRoute(GPXFile gpx) {
if(gpx == null) {
if (gpx == null) {
currentRoute = null;
} else {
currentRoute = new SelectedRouteGpxFile(gpx);
}
}
@Override
public void destinationReached() {
if(currentRoute != null) {
currentRoute.naviateToNextPoint();
public boolean destinationReached() {
if (currentRoute != null) {
boolean naviateToNextPoint = currentRoute.naviateToNextPoint();
if (naviateToNextPoint) {
return false;
}
}
return true;
}
@Override
@ -93,11 +99,23 @@ public class RoutePointsPlugin extends OsmandPlugin {
if (mapInfoLayer != null) {
routeStepsControl = createRouteStepsInfoControl(activity, mapInfoLayer.getPaintSubText(), mapInfoLayer.getPaintSubText());
mapInfoLayer.getMapInfoControls().registerSideWidget(routeStepsControl,
R.drawable.widget_target, R.string.map_widget_route_points, "route_steps", false, 8);
R.drawable.ic_signpost, R.string.map_widget_route_points, "route_steps", false, 8);
mapInfoLayer.recreateControls();
}
}
@Override
public void registerLayers(MapActivity activity) {
super.registerLayers(activity);
if (routePointsLayer != null) {
activity.getMapView().removeLayer(routePointsLayer);
}
routePointsLayer = new RoutePointsLayer(activity, this);
activity.getMapView().addLayer(routePointsLayer, 5.5f);
registerWidget(activity);
}
@Override
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
@ -134,44 +152,45 @@ public class RoutePointsPlugin extends OsmandPlugin {
}
});
routeStepsControl.setText(null, null);
routeStepsControl.setImageDrawable(map.getResources().getDrawable(R.drawable.widget_target));
routeStepsControl.setImageDrawable(map.getResources().getDrawable(R.drawable.ic_signpost));
return routeStepsControl;
}
public class RoutePoint {
boolean isNextNavigate;
int gpxOrder;
long visitedTime; // 0 not visited
WptPt wpt;
public String getName() {
return wpt.name;
}
public WptPt getWpt() {
return wpt;
}
public boolean isNextNavigate() {
return isNextNavigate;
}
public boolean isVisited() {
return visitedTime != 0;
}
public int getGpxOrder() {
return gpxOrder;
}
public String getDistance(RoutePoint rp) {
double d = MapUtils.getDistance(rp.getPoint(), getPoint());
String distance = OsmAndFormatter.getFormattedDistance((float) d, app);
return distance;
}
public String getTime() {
if(visitedTime == 0) {
if (visitedTime == 0) {
return "";
}
String dateString;
@ -183,86 +202,87 @@ public class RoutePointsPlugin extends OsmandPlugin {
}
return dateString;
}
public LatLon getPoint() {
return new LatLon(wpt.lat, wpt.lon);
}
public void setVisitedTime(long currentTimeMillis) {
visitedTime = currentTimeMillis;
wpt.getExtensionsToWrite().put(VISITED_KEY, visitedTime+"");
wpt.getExtensionsToWrite().put(VISITED_KEY, visitedTime + "");
}
}
public class SelectedRouteGpxFile {
private GPXUtilities.GPXFile gpx;
private List<RoutePoint> currentPoints = new ArrayList<RoutePointsPlugin.RoutePoint>();
public SelectedRouteGpxFile(GPXUtilities.GPXFile gpx) {
this.gpx = gpx;
parseGPXFile(gpx);
}
public List<RoutePoint> getCurrentPoints() {
return currentPoints;
}
public int getVisitedCount() {
int k = 0;
for(RoutePoint rp : currentPoints) {
if(rp.isVisited()) {
for (RoutePoint rp : currentPoints) {
if (rp.isVisited()) {
k++;
}
}
return k;
}
public int getCount() {
return currentPoints.size();
}
public GPXUtilities.Route getRoute() {
if(gpx.routes.isEmpty()) {
if (gpx.routes.isEmpty()) {
return null;
}
return gpx.routes.get(0);
}
public String saveFile() {
return GPXUtilities.writeGpxFile(new File(gpx.path), gpx, app);
}
public void markPoint(RoutePoint point, boolean visited) {
if(point.isNextNavigate() && visited) {
if (point.isNextNavigate() && visited) {
naviateToNextPoint();
return;
}
if(visited) {
if (visited) {
point.setVisitedTime(System.currentTimeMillis());
} else {
point.setVisitedTime(0);
}
sortPoints();
}
public void naviateToNextPoint() {
if(!currentPoints.isEmpty()) {
public boolean naviateToNextPoint() {
if (!currentPoints.isEmpty()) {
RoutePoint rp = currentPoints.get(0);
if(rp.isNextNavigate) {
if (rp.isNextNavigate) {
rp.setVisitedTime(System.currentTimeMillis());
sortPoints();
}
RoutePoint first = currentPoints.get(0);
if(!first.isVisited()) {
if (!first.isVisited()) {
app.getTargetPointsHelper().navigateToPoint(first.getPoint(), true, -1, first.getName());
first.isNextNavigate = true;
return true;
} else {
app.getTargetPointsHelper().clearPointToNavigate(true);
}
}
return false;
}
private void sortPoints() {
@ -270,32 +290,36 @@ public class RoutePointsPlugin extends OsmandPlugin {
@Override
public int compare(RoutePoint lhs, RoutePoint rhs) {
if(lhs.isNextNavigate || rhs.isNextNavigate) {
return lhs.isNextNavigate? -1 : 1;
if (lhs.isNextNavigate || rhs.isNextNavigate) {
return lhs.isNextNavigate ? -1 : 1;
}
if(!lhs.isVisited() || !rhs.isVisited()) {
if(lhs.isVisited()) {
if (!lhs.isVisited() || !rhs.isVisited()) {
if (lhs.isVisited()) {
return 1;
}
if(rhs.isVisited()) {
if (rhs.isVisited()) {
return -1;
}
return Integer.compare(lhs.gpxOrder, rhs.gpxOrder);
return lcompare(lhs.gpxOrder, rhs.gpxOrder);
}
return -Long.compare(lhs.visitedTime, rhs.visitedTime);
return -lcompare(lhs.visitedTime, rhs.visitedTime);
}
public int lcompare(long lhs, long rhs) {
return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1);
}
});
}
private void parseGPXFile(GPXFile gpx) {
this.gpx = gpx;
Route rt = getRoute();
currentPoints.clear();
if(rt != null) {
if (rt != null) {
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
String locName = targetPointsHelper.getPointNavigateDescription();
for(int i = 0; i < rt.points.size(); i++) {
for (int i = 0; i < rt.points.size(); i++) {
WptPt wptPt = rt.points.get(i);
RoutePoint rtp = new RoutePoint();
rtp.gpxOrder = i;
@ -306,7 +330,7 @@ public class RoutePointsPlugin extends OsmandPlugin {
} catch (NumberFormatException e) {
}
rtp.isNextNavigate = rtp.visitedTime == 0 && locName != null && locName.equals(wptPt.name);
if(rtp.isNextNavigate) {
if (rtp.isNextNavigate) {
locName = null;
}
currentPoints.add(rtp);
@ -333,17 +357,40 @@ public class RoutePointsPlugin extends OsmandPlugin {
public void updateCurrentTargetPoint() {
TargetPointsHelper targetPointsHelper = app.getTargetPointsHelper();
String locName = targetPointsHelper.getPointNavigateDescription();
for(int i = 0; i < currentPoints.size(); i++) {
for (int i = 0; i < currentPoints.size(); i++) {
RoutePoint rtp = currentPoints.get(i);
rtp.isNextNavigate = rtp.visitedTime == 0 && locName != null && locName.equals(rtp.getName());
if(rtp.isNextNavigate) {
if (rtp.isNextNavigate) {
locName = null;
}
}
sortPoints();
}
}
public boolean getPointStatus(WptPt p) {
RoutePoint point = getRoutePointFromWpt(p);
return point != null && (point.isVisited());
}
public void markPoint(WptPt point, boolean visited) {
markPoint(getRoutePointFromWpt(point), visited);
}
public void navigateToPoint(WptPt point) {
navigateToPoint(getRoutePointFromWpt(point));
}
public RoutePoint getRoutePointFromWpt(WptPt point) {
if (currentPoints != null) {
for (RoutePoint find : currentPoints) {
WptPt itemToFind = find.getWpt();
if (itemToFind.equals(point)) {
return find;
}
}
}
return null;
}
}
}

View file

@ -434,16 +434,17 @@ public class RoutingHelper {
if(isFollowingMode) {
voiceRouter.arrivedDestinationPoint(description);
}
clearCurrentRoute(null, null);
setRoutePlanningMode(false);
OsmandPlugin.onDestinationReached();
app.runInUIThread(new Runnable() {
@Override
public void run() {
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
}
});
if (OsmandPlugin.onDestinationReached()) {
clearCurrentRoute(null, null);
setRoutePlanningMode(false);
OsmandPlugin.onDestinationReached();
app.runInUIThread(new Runnable() {
@Override
public void run() {
settings.APPLICATION_MODE.set(settings.DEFAULT_APPLICATION_MODE.get());
}
});
}
// targets.clearPointToNavigate(false);
return true;
}

View file

@ -111,10 +111,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
// request to load
final QuadRect latLonBounds = tileBox.getLatLonBounds();
for (SelectedGpxFile g : selectedGPXFiles) {
List<WptPt> pts = g.getGpxFile().points;
if(pts.isEmpty() & !g.getGpxFile().routes.isEmpty()) {
pts = g.getGpxFile().routes.get(0).points;
}
List<WptPt> pts = getListStarPoints(g);
int fcolor = g.getColor() == 0 ? defPointColor : g.getColor();
for (WptPt o : pts) {
@ -142,6 +139,14 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
}
}
private List<WptPt> getListStarPoints(SelectedGpxFile g) {
List<WptPt> pts = g.getGpxFile().points;
if(pts.isEmpty() & !g.getGpxFile().routes.isEmpty()) {
pts = g.getGpxFile().routes.get(0).points;
}
return pts;
}
private void drawSegments(Canvas canvas, RotatedTileBox tileBox, List<List<WptPt>> points) {
final QuadRect latLonBounds = tileBox.getLatLonBounds();
for (List<WptPt> l : points) {
@ -197,7 +202,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
int ex = (int) point.x;
int ey = (int) point.y;
for (SelectedGpxFile g : selectedGpxHelper.getSelectedGPXFiles()) {
List<WptPt> pts = g.getGpxFile().points;
List<WptPt> pts = getListStarPoints(g);
// int fcolor = g.getColor() == 0 ? clr : g.getColor();
for (WptPt n : pts) {
int x = (int) tb.getPixXFromLatLon(n.lat, n.lon);