Search in sources :

Example 1 with OnlineRoutingEngine

use of net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine in project Osmand by osmandapp.

the class OnlineRoutingSettingsItem method renameItem.

@NonNull
@Override
public OnlineRoutingEngine renameItem(@NonNull OnlineRoutingEngine item) {
    OnlineRoutingEngine renamedItem = (OnlineRoutingEngine) item.clone();
    OnlineRoutingUtils.generateUniqueName(app, renamedItem, otherEngines);
    renamedItem.remove(EngineParameter.KEY);
    otherEngines.add(renamedItem);
    return renamedItem;
}
Also used : OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) NonNull(androidx.annotation.NonNull)

Example 2 with OnlineRoutingEngine

use of net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine in project Osmand by osmandapp.

the class OnlineRoutingHelper method getEnginesExceptMentionedKeys.

@NonNull
public List<OnlineRoutingEngine> getEnginesExceptMentionedKeys(@Nullable String... excludeKeys) {
    List<OnlineRoutingEngine> engines = getEngines();
    if (excludeKeys != null) {
        for (String key : excludeKeys) {
            OnlineRoutingEngine engine = getEngineByKey(key);
            engines.remove(engine);
        }
    }
    return engines;
}
Also used : OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) NonNull(androidx.annotation.NonNull)

Example 3 with OnlineRoutingEngine

use of net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine in project Osmand by osmandapp.

the class OnlineRoutingUtils method readFromJson.

public static void readFromJson(@NonNull JSONObject json, @NonNull List<OnlineRoutingEngine> engines) throws JSONException {
    if (!json.has("items")) {
        return;
    }
    Gson gson = new Gson();
    Type typeToken = new TypeToken<HashMap<String, String>>() {
    }.getType();
    JSONArray itemsJson = json.getJSONArray(ITEMS);
    for (int i = 0; i < itemsJson.length(); i++) {
        JSONObject object = itemsJson.getJSONObject(i);
        if (object.has(TYPE) && object.has(PARAMS)) {
            OnlineRoutingEngine type = EngineType.getTypeByName(object.getString(TYPE));
            String paramsString = object.getString(PARAMS);
            HashMap<String, String> params = gson.fromJson(paramsString, typeToken);
            OnlineRoutingEngine engine = type.newInstance(params);
            if (!Algorithms.isEmpty(engine.getStringKey())) {
                engines.add(engine);
            }
        }
    }
}
Also used : EngineType(net.osmand.plus.onlinerouting.engine.EngineType) Type(java.lang.reflect.Type) OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) JSONObject(org.json.JSONObject) HashMap(java.util.HashMap) JSONArray(org.json.JSONArray) Gson(com.google.gson.Gson)

Example 4 with OnlineRoutingEngine

use of net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine in project Osmand by osmandapp.

the class SelectNavProfileBottomSheet method savePredefinedEngine.

private void savePredefinedEngine(RoutingDataObject profile) {
    String stringKey = profile.getStringKey();
    OnlineRoutingHelper helper = app.getOnlineRoutingHelper();
    ProfilesGroup profilesGroup = findGroupOfProfile(profile);
    if (profilesGroup != null) {
        PredefinedProfilesGroup group = (PredefinedProfilesGroup) profilesGroup;
        String type = group.getType().toUpperCase();
        OnlineRoutingEngine engine = EngineType.getTypeByName(type).newInstance(null);
        engine.put(EngineParameter.KEY, stringKey);
        engine.put(EngineParameter.VEHICLE_KEY, NONE_VEHICLE.getKey());
        engine.put(EngineParameter.CUSTOM_URL, profile.getDescription());
        String namePattern = getString(R.string.ltr_or_rtl_combine_via_dash);
        String name = String.format(namePattern, group.getTitle(), profile.getName());
        engine.put(EngineParameter.CUSTOM_NAME, name);
        helper.saveEngine(engine);
    }
}
Also used : PredefinedProfilesGroup(net.osmand.plus.profiles.data.PredefinedProfilesGroup) OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) OnlineRoutingHelper(net.osmand.plus.onlinerouting.OnlineRoutingHelper) ProfilesGroup(net.osmand.plus.profiles.data.ProfilesGroup) PredefinedProfilesGroup(net.osmand.plus.profiles.data.PredefinedProfilesGroup)

Example 5 with OnlineRoutingEngine

use of net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine in project Osmand by osmandapp.

the class RoutingDataUtils method getOnlineRoutingProfiles.

private List<ProfileDataObject> getOnlineRoutingProfiles(boolean onlyCustom) {
    OnlineRoutingHelper helper = app.getOnlineRoutingHelper();
    List<ProfileDataObject> objects = new ArrayList<>();
    List<OnlineRoutingEngine> engines = onlyCustom ? helper.getOnlyCustomEngines() : helper.getEngines();
    for (int i = 0; i < engines.size(); i++) {
        OnlineRoutingDataObject profile = convertOnlineEngineToDataObject(engines.get(i));
        profile.setOrder(i);
        objects.add(profile);
    }
    return objects;
}
Also used : OnlineRoutingEngine(net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine) ArrayList(java.util.ArrayList) OnlineRoutingHelper(net.osmand.plus.onlinerouting.OnlineRoutingHelper)

Aggregations

OnlineRoutingEngine (net.osmand.plus.onlinerouting.engine.OnlineRoutingEngine)22 ArrayList (java.util.ArrayList)8 File (java.io.File)6 ITileSource (net.osmand.map.ITileSource)6 AvoidRoadInfo (net.osmand.plus.helpers.AvoidSpecificRoads.AvoidRoadInfo)5 HistoryEntry (net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry)5 MapMarkersGroup (net.osmand.plus.mapmarkers.MapMarkersGroup)5 FavoriteGroup (net.osmand.plus.myplaces.FavoriteGroup)5 PoiUIFilter (net.osmand.plus.poi.PoiUIFilter)5 QuickAction (net.osmand.plus.quickaction.QuickAction)5 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)5 OpenstreetmapPoint (net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint)4 OsmNotesPoint (net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)4 ApplicationModeBean (net.osmand.plus.settings.backend.ApplicationMode.ApplicationModeBean)4 NonNull (androidx.annotation.NonNull)3 MapMarker (net.osmand.plus.mapmarkers.MapMarker)3 OnlineRoutingHelper (net.osmand.plus.onlinerouting.OnlineRoutingHelper)3 SQLiteTileSource (net.osmand.plus.resources.SQLiteTileSource)3 FileSettingsItem (net.osmand.plus.settings.backend.backup.items.FileSettingsItem)3 GlobalSettingsItem (net.osmand.plus.settings.backend.backup.items.GlobalSettingsItem)3