Implement Online routing backend (fixes after code review)
This commit is contained in:
parent
febc0822e6
commit
cb1f203cc1
31 changed files with 36 additions and 40 deletions
|
@ -4023,7 +4023,6 @@
|
|||
<string name="routing_engine_vehicle_type_foot">قدم</string>
|
||||
<string name="routing_engine_vehicle_type_bike">دراجة هوائية</string>
|
||||
<string name="routing_engine_vehicle_type_car">سيارة</string>
|
||||
<string name="message_error_recheck_parameters">خطأ، أعد التحقق من المعايير</string>
|
||||
<string name="copy_address">نسخ العنوان</string>
|
||||
<string name="online_routing_engine">محرك التوجيه عبر الإنترنت</string>
|
||||
<string name="online_routing_engines">محركات التوجيه عبر الإنترنت</string>
|
||||
|
|
|
@ -3960,7 +3960,6 @@
|
|||
<string name="routing_engine_vehicle_type_foot">Chůze</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Kolo</string>
|
||||
<string name="routing_engine_vehicle_type_car">Auto</string>
|
||||
<string name="message_error_recheck_parameters">Chyba, zkontrolujte parametry</string>
|
||||
<string name="copy_address">Kopírovat adresu</string>
|
||||
<string name="online_routing_engine">Online navigační služba</string>
|
||||
<string name="online_routing_engines">Online navigační služby</string>
|
||||
|
|
|
@ -3962,7 +3962,6 @@
|
|||
<string name="routing_engine_vehicle_type_foot">Zu Fuß</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Fahrrad</string>
|
||||
<string name="routing_engine_vehicle_type_car">Auto</string>
|
||||
<string name="message_error_recheck_parameters">Fehler, Parameter erneut prüfen</string>
|
||||
<string name="shared_string_subtype">Subtyp</string>
|
||||
<string name="keep_it_empty_if_not">Leer lassen, wenn kein API-Schlüssel vorhanden</string>
|
||||
<string name="copy_address">Adresse kopieren</string>
|
||||
|
|
|
@ -3960,7 +3960,6 @@
|
|||
<string name="routing_engine_vehicle_type_foot">Piediranto</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Biciklo</string>
|
||||
<string name="routing_engine_vehicle_type_car">Aŭtomobilo</string>
|
||||
<string name="message_error_recheck_parameters">Eraro, rekontrolu parametrojn</string>
|
||||
<string name="copy_address">Kopii adreson</string>
|
||||
<string name="online_routing_engine">Enreta navigilo</string>
|
||||
<string name="online_routing_engines">Enretaj navigiloj</string>
|
||||
|
|
|
@ -3963,7 +3963,6 @@
|
|||
<string name="routing_engine_vehicle_type_foot">Peatón</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Bicicleta</string>
|
||||
<string name="routing_engine_vehicle_type_car">Automóvil</string>
|
||||
<string name="message_error_recheck_parameters">Error, vuelve a comprobar los parámetros</string>
|
||||
<string name="copy_address">Copiar dirección</string>
|
||||
<string name="online_routing_engine">Motor de navegación en línea</string>
|
||||
<string name="online_routing_engines">Motores de navegación en línea</string>
|
||||
|
|
|
@ -3933,6 +3933,5 @@ Area honi dagokio: %1$s x %2$s</string>
|
|||
<string name="routing_engine_vehicle_type_foot">Oinez</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Bizikleta</string>
|
||||
<string name="routing_engine_vehicle_type_car">Kotxea</string>
|
||||
<string name="message_error_recheck_parameters">Errorea, egiaztatu parametroak berriro</string>
|
||||
<string name="copy_address">Kopiatu helbidea</string>
|
||||
</resources>
|
|
@ -3953,5 +3953,4 @@
|
|||
<string name="routing_engine_vehicle_type_foot">پا</string>
|
||||
<string name="routing_engine_vehicle_type_bike">دوچرخه</string>
|
||||
<string name="routing_engine_vehicle_type_car">خودرو</string>
|
||||
<string name="message_error_recheck_parameters">خطا، پارامترها را بازبینی کنید</string>
|
||||
</resources>
|
|
@ -3947,7 +3947,6 @@
|
|||
<string name="routing_engine_vehicle_type_foot">A pieds</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Vélo</string>
|
||||
<string name="routing_engine_vehicle_type_car">Automobile</string>
|
||||
<string name="message_error_recheck_parameters">Erreur, vérifiez les paramètres</string>
|
||||
<string name="add_online_routing_engine">Ajouter un moteur de routage en ligne</string>
|
||||
<string name="edit_online_routing_engine">Modifier le moteur de routage en ligne</string>
|
||||
<string name="online_routing_example_hint">L\'URL avec tous les paramètres sera de la forme :</string>
|
||||
|
|
|
@ -3968,7 +3968,6 @@ Lon %2$s</string>
|
|||
<string name="routing_engine_vehicle_type_foot">Pé</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Bicicleta</string>
|
||||
<string name="routing_engine_vehicle_type_car">Coche</string>
|
||||
<string name="message_error_recheck_parameters">Erro, verifica novamente os parámetros</string>
|
||||
<string name="copy_address">Copiar enderezo</string>
|
||||
<string name="voice_prompts_timetable">Horarios dos avisos por voz</string>
|
||||
<string name="online_routing_engine">Motor de navegación en liña</string>
|
||||
|
|
|
@ -3954,7 +3954,6 @@
|
|||
<string name="keep_it_empty_if_not">Hagyja üresen, ha nem</string>
|
||||
<string name="online_routing_example_hint">Az összes paraméterrel rendelkező URL így néz ki:</string>
|
||||
<string name="test_route_calculation">Útvonaltervezés kipróbálása</string>
|
||||
<string name="message_error_recheck_parameters">Hiba, ellenőrizze újra a paramétereket</string>
|
||||
<string name="copy_address">Cím másolása</string>
|
||||
<string name="online_routing_engine">Online útvonaltervező</string>
|
||||
<string name="online_routing_engines">Online útvonaltervezők</string>
|
||||
|
|
|
@ -3965,6 +3965,5 @@
|
|||
<string name="routing_engine_vehicle_type_foot">Gangandi</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Hjólandi</string>
|
||||
<string name="routing_engine_vehicle_type_car">Bíll</string>
|
||||
<string name="message_error_recheck_parameters">Villa, yfirfarðu breytur</string>
|
||||
<string name="copy_address">Afrita heimilisfang</string>
|
||||
</resources>
|
|
@ -3963,7 +3963,6 @@
|
|||
<string name="routing_engine_vehicle_type_foot">ברגל</string>
|
||||
<string name="routing_engine_vehicle_type_bike">אופנוע</string>
|
||||
<string name="routing_engine_vehicle_type_car">מכונית</string>
|
||||
<string name="message_error_recheck_parameters">שגיאה, נא לבדוק את המשתנים מחדש</string>
|
||||
<string name="copy_address">העתקת כתובת</string>
|
||||
<string name="online_routing_engine">מנוע ניווט מקוון</string>
|
||||
<string name="online_routing_engines">מנועי ניווט מקוונים</string>
|
||||
|
|
|
@ -2449,7 +2449,6 @@
|
|||
<string name="subscription_paused_title">OsmAndის გამოწერა დაპაუზებულია</string>
|
||||
<string name="subscription_on_hold_title">OsmAndის გამოწერა შეჩერებულია</string>
|
||||
<string name="online_routing_example_hint">URL ყველა პარამეტრით აი ასეთი იქნება:</string>
|
||||
<string name="message_error_recheck_parameters">შეცდომა, გადაამოწმეთ პარამეტრები</string>
|
||||
<string name="mapillary_image">Mapillary-ის გამოსახულება</string>
|
||||
<string name="mapillary_widget">Mapillary-ის ღილაკი</string>
|
||||
<string name="srtm_color_scheme">ფერთა გამა</string>
|
||||
|
|
|
@ -2770,7 +2770,6 @@ Tai yra puikus būdas paremti OsmAnd ir OSM, jei jie jums patinka.</string>
|
|||
<string name="test_route_calculation">Patikrinti maršruto apskaičiavimą</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Dviratis</string>
|
||||
<string name="routing_engine_vehicle_type_car">Automobilis</string>
|
||||
<string name="message_error_recheck_parameters">Įvyko klaida, patikrinkite paametrus</string>
|
||||
<string name="copy_address">Kopijuoti adresą</string>
|
||||
<string name="shared_string_folders">Folderiai</string>
|
||||
<string name="select_folder">Pasirinkite folderį</string>
|
||||
|
|
|
@ -3916,7 +3916,6 @@
|
|||
<string name="routing_engine_vehicle_type_foot">Te voet</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Fiets</string>
|
||||
<string name="routing_engine_vehicle_type_car">Auto</string>
|
||||
<string name="message_error_recheck_parameters">Fout, controleer parameters opnieuw</string>
|
||||
<string name="copy_address">Kopieer adres</string>
|
||||
<string name="online_routing_engine">Online routeplanningssysteem</string>
|
||||
<string name="online_routing_engines">Online routeplanningssystemen</string>
|
||||
|
|
|
@ -3956,7 +3956,6 @@
|
|||
<string name="test_route_calculation">Obliczanie trasy testowej</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Rower</string>
|
||||
<string name="routing_engine_vehicle_type_car">Samochód</string>
|
||||
<string name="message_error_recheck_parameters">Błąd, ponownie sprawdź parametry</string>
|
||||
<string name="copy_address">Skopiuj adres</string>
|
||||
<string name="routing_engine_vehicle_type_driving">Jazda</string>
|
||||
<string name="routing_engine_vehicle_type_foot">Stopa</string>
|
||||
|
|
|
@ -3955,7 +3955,6 @@
|
|||
<string name="routing_engine_vehicle_type_foot">Pé</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Bicicleta</string>
|
||||
<string name="routing_engine_vehicle_type_car">Carro</string>
|
||||
<string name="message_error_recheck_parameters">Erro, verifique novamente os parâmetros</string>
|
||||
<string name="copy_address">Copiar endereço</string>
|
||||
<string name="online_routing_engine">Motor de encaminhamento online</string>
|
||||
<string name="online_routing_engines">Mecanismos de roteamento online</string>
|
||||
|
|
|
@ -3957,7 +3957,6 @@
|
|||
<string name="routing_engine_vehicle_type_foot">A pee</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Bitzicleta</string>
|
||||
<string name="routing_engine_vehicle_type_car">Màchina</string>
|
||||
<string name="message_error_recheck_parameters">Errore, torra a verificare sos paràmetros</string>
|
||||
<string name="copy_address">Còpia s\'indiritzu</string>
|
||||
<string name="online_routing_engine">Motore de càrculu in lìnia</string>
|
||||
<string name="online_routing_engines">Motores de càrculu in lìnia</string>
|
||||
|
|
|
@ -3955,7 +3955,6 @@
|
|||
<string name="routing_engine_vehicle_type_foot">Chôdza</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Bicykel</string>
|
||||
<string name="routing_engine_vehicle_type_car">Auto</string>
|
||||
<string name="message_error_recheck_parameters">Chyba, skontrolujte parametre</string>
|
||||
<string name="copy_address">Kopírovať adresu</string>
|
||||
<string name="online_routing_engine">Online navigačná služba</string>
|
||||
<string name="online_routing_engines">Online navigačné služby</string>
|
||||
|
|
|
@ -3961,7 +3961,6 @@
|
|||
<string name="routing_engine_vehicle_type_foot">Yürüme</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Bisiklet</string>
|
||||
<string name="routing_engine_vehicle_type_car">Araba</string>
|
||||
<string name="message_error_recheck_parameters">Hata, parametreleri tekrar gözden geçirin</string>
|
||||
<string name="copy_address">Adresi kopyala</string>
|
||||
<string name="online_routing_engine">Çevrim içi yönlendirme motoru</string>
|
||||
<string name="online_routing_engines">Çevrim içi yönlendirme motorları</string>
|
||||
|
|
|
@ -3959,7 +3959,6 @@
|
|||
<string name="routing_engine_vehicle_type_foot">Пішки</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Велосипед</string>
|
||||
<string name="routing_engine_vehicle_type_car">Автомобіль</string>
|
||||
<string name="message_error_recheck_parameters">Помилка, повторно перевірте параметри</string>
|
||||
<string name="copy_address">Копіювати адресу</string>
|
||||
<string name="online_routing_engine">Мережний рушій маршрутизації</string>
|
||||
<string name="online_routing_engines">Мережні рушії маршрутизації</string>
|
||||
|
|
|
@ -3953,7 +3953,6 @@
|
|||
<string name="routing_engine_vehicle_type_foot">步行</string>
|
||||
<string name="routing_engine_vehicle_type_bike">自行車</string>
|
||||
<string name="routing_engine_vehicle_type_car">汽車</string>
|
||||
<string name="message_error_recheck_parameters">錯誤,重新檢查參數</string>
|
||||
<string name="copy_address">複製地址</string>
|
||||
<string name="online_routing_engine">線上路線計算引擎</string>
|
||||
<string name="online_routing_engines">線上路線計算引擎</string>
|
||||
|
|
|
@ -12,6 +12,21 @@
|
|||
|
||||
-->
|
||||
|
||||
<string name="message_name_is_already_exists">The name is already exists</string>
|
||||
<string name="message_server_error">Server error: %1$s</string>
|
||||
<string name="routing_engine_vehicle_type_mtb">MTB</string>
|
||||
<string name="routing_engine_vehicle_type_racingbike">Racing bike</string>
|
||||
<string name="routing_engine_vehicle_type_scooter">Scooter</string>
|
||||
<string name="routing_engine_vehicle_type_truck">Truck</string>
|
||||
<string name="routing_engine_vehicle_type_small_truck">Small truck</string>
|
||||
<string name="routing_engine_vehicle_type_hgv">HGV</string>
|
||||
<string name="routing_engine_vehicle_type_cycling_regular">Regular cycling</string>
|
||||
<string name="routing_engine_vehicle_type_cycling_road">Road cycling</string>
|
||||
<string name="routing_engine_vehicle_type_cycling_mountain">Mountain cycling</string>
|
||||
<string name="routing_engine_vehicle_type_cycling_electric">Electric cycling</string>
|
||||
<string name="routing_engine_vehicle_type_walking">Walking</string>
|
||||
<string name="routing_engine_vehicle_type_hiking">Hiking</string>
|
||||
<string name="routing_engine_vehicle_type_wheelchair">Wheelchair</string>
|
||||
<string name="announcement_time_title">Announcement time</string>
|
||||
<string name="announcement_time_descr">Announcement time of different voice prompts depends on prompt type, current navigation speed and default navigation speed.</string>
|
||||
<string name="announcement_time_intervals">Time and distance intervals</string>
|
||||
|
@ -35,7 +50,6 @@
|
|||
<string name="online_routing_engines">Online routing engines</string>
|
||||
<string name="online_routing_engine">Online routing engine</string>
|
||||
<string name="copy_address">Copy address</string>
|
||||
<string name="message_error_recheck_parameters">Error, recheck parameters</string>
|
||||
<string name="routing_engine_vehicle_type_car">Car</string>
|
||||
<string name="routing_engine_vehicle_type_bike">Bike</string>
|
||||
<string name="routing_engine_vehicle_type_foot">Foot</string>
|
||||
|
|
|
@ -156,7 +156,7 @@ public class OnlineRoutingHelper {
|
|||
try {
|
||||
JSONObject json = new JSONObject(jsonString);
|
||||
readFromJson(json, engines);
|
||||
} catch (JSONException e) {
|
||||
} catch (JSONException | IllegalArgumentException e) {
|
||||
LOG.debug("Error when reading engines from JSON ", e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ import org.json.JSONObject;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.util.Algorithms.isEmpty;
|
||||
|
||||
public class GraphhopperEngine extends OnlineRoutingEngine {
|
||||
|
||||
public GraphhopperEngine(@Nullable Map<String, String> params) {
|
||||
|
@ -62,11 +64,11 @@ public class GraphhopperEngine extends OnlineRoutingEngine {
|
|||
.append('&');
|
||||
}
|
||||
String vehicle = get(EngineParameter.VEHICLE_KEY);
|
||||
if (vehicle != null) {
|
||||
if (isEmpty(vehicle)) {
|
||||
sb.append("vehicle=").append(vehicle);
|
||||
}
|
||||
String apiKey = get(EngineParameter.API_KEY);
|
||||
if (apiKey != null) {
|
||||
if (isEmpty(apiKey)) {
|
||||
sb.append('&').append("key=").append(apiKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static net.osmand.util.Algorithms.isEmpty;
|
||||
|
||||
public abstract class OnlineRoutingEngine implements Cloneable {
|
||||
|
||||
public final static String ONLINE_ROUTING_ENGINE_PREFIX = "online_routing_engine_";
|
||||
|
@ -33,7 +35,7 @@ public abstract class OnlineRoutingEngine implements Cloneable {
|
|||
private final Set<EngineParameter> allowedParameters = new HashSet<>();
|
||||
|
||||
public OnlineRoutingEngine(@Nullable Map<String, String> params) {
|
||||
if (!Algorithms.isEmpty(params)) {
|
||||
if (!isEmpty(params)) {
|
||||
this.params.putAll(params);
|
||||
}
|
||||
collectAllowedVehiclesInternal();
|
||||
|
@ -62,13 +64,13 @@ public abstract class OnlineRoutingEngine implements Cloneable {
|
|||
private String getStandardName(@NonNull Context ctx) {
|
||||
String base = getBaseName(ctx);
|
||||
String index = get(EngineParameter.NAME_INDEX);
|
||||
return !Algorithms.isEmpty(index) ? base + " " + index : base;
|
||||
return !isEmpty(index) ? base + " " + index : base;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getBaseName(@NonNull Context ctx) {
|
||||
String vehicleTitle = getSelectedVehicleName(ctx);
|
||||
if (Algorithms.isEmpty(vehicleTitle)) {
|
||||
if (isEmpty(vehicleTitle)) {
|
||||
return getType().getTitle();
|
||||
} else {
|
||||
String pattern = ctx.getString(R.string.ltr_or_rtl_combine_via_dash);
|
||||
|
@ -79,7 +81,7 @@ public abstract class OnlineRoutingEngine implements Cloneable {
|
|||
@NonNull
|
||||
public String getBaseUrl() {
|
||||
String customUrl = get(EngineParameter.CUSTOM_URL);
|
||||
if (Algorithms.isEmpty(customUrl)) {
|
||||
if (isEmpty(customUrl)) {
|
||||
return getStandardUrl();
|
||||
}
|
||||
return customUrl;
|
||||
|
@ -186,10 +188,6 @@ public abstract class OnlineRoutingEngine implements Cloneable {
|
|||
return OnlineRoutingFactory.createEngine(getType(), getParams());
|
||||
}
|
||||
|
||||
protected boolean isEmpty(@Nullable String s) {
|
||||
return Algorithms.isEmpty(s);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String generateKey() {
|
||||
return ONLINE_ROUTING_ENGINE_PREFIX + System.currentTimeMillis();
|
||||
|
|
|
@ -16,6 +16,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.util.Algorithms.isEmpty;
|
||||
|
||||
public class OrsEngine extends OnlineRoutingEngine {
|
||||
|
||||
public OrsEngine(@Nullable Map<String, String> params) {
|
||||
|
|
|
@ -15,6 +15,8 @@ import org.json.JSONObject;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.util.Algorithms.isEmpty;
|
||||
|
||||
public class OsrmEngine extends OnlineRoutingEngine {
|
||||
|
||||
public OsrmEngine(@Nullable Map<String, String> params) {
|
||||
|
|
|
@ -156,7 +156,7 @@ public class OnlineRoutingCard extends BaseCard {
|
|||
public void hideFieldBoxError() {
|
||||
hideElements(tvErrorText);
|
||||
if (fieldBoxHelperTextShowed) {
|
||||
showElements(tvErrorText);
|
||||
showElements(tvHelperText);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,10 @@ public class OnlineRoutingEngineDataObject extends ProfileDataObject {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NonNull ProfileDataObject another) {
|
||||
if (another instanceof OnlineRoutingEngineDataObject) {
|
||||
OnlineRoutingEngineDataObject anotherEngine = (OnlineRoutingEngineDataObject) another;
|
||||
return Integer.compare(this.order, anotherEngine.order);
|
||||
public int compareTo(@NonNull ProfileDataObject profileDataObject) {
|
||||
if (profileDataObject instanceof OnlineRoutingEngineDataObject) {
|
||||
OnlineRoutingEngineDataObject another = (OnlineRoutingEngineDataObject) profileDataObject;
|
||||
return (this.order < another.order) ? -1 : ((this.order == another.order) ? 0 : 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ public class OnlineRoutingSettingsItem extends CollectionSettingsItem<OnlineRout
|
|||
void readItemsFromJson(@NonNull JSONObject json) throws IllegalArgumentException {
|
||||
try {
|
||||
OnlineRoutingHelper.readFromJson(json, items);
|
||||
} catch (JSONException e) {
|
||||
} catch (JSONException | IllegalArgumentException e) {
|
||||
warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType())));
|
||||
throw new IllegalArgumentException("Json parse error", e);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue