Merge pull request #808 from afischerdev/apk-profileparams
Apk: Use profile parameter
This commit is contained in:
commit
26925a1e1a
2 changed files with 33 additions and 3 deletions
|
|
@ -30,6 +30,7 @@ import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
|
|
@ -44,6 +45,8 @@ import btools.router.OsmTrack;
|
||||||
import btools.router.RoutingContext;
|
import btools.router.RoutingContext;
|
||||||
import btools.router.RoutingEngine;
|
import btools.router.RoutingEngine;
|
||||||
import btools.router.RoutingHelper;
|
import btools.router.RoutingHelper;
|
||||||
|
import btools.router.RoutingParamCollector;
|
||||||
|
|
||||||
import btools.util.CheapRuler;
|
import btools.util.CheapRuler;
|
||||||
|
|
||||||
public class BRouterView extends View {
|
public class BRouterView extends View {
|
||||||
|
|
@ -437,6 +440,7 @@ public class BRouterView extends View {
|
||||||
|
|
||||||
public void startProcessing(String profile) {
|
public void startProcessing(String profile) {
|
||||||
rawTrackPath = null;
|
rawTrackPath = null;
|
||||||
|
String params = null;
|
||||||
if (profile.startsWith("<repeat")) {
|
if (profile.startsWith("<repeat")) {
|
||||||
needsViaSelection = needsNogoSelection = needsWaypointSelection = false;
|
needsViaSelection = needsNogoSelection = needsWaypointSelection = false;
|
||||||
try {
|
try {
|
||||||
|
|
@ -446,6 +450,7 @@ public class BRouterView extends View {
|
||||||
rawTrackPath = br.readLine();
|
rawTrackPath = br.readLine();
|
||||||
wpList = readWpList(br, false);
|
wpList = readWpList(br, false);
|
||||||
nogoList = readWpList(br, true);
|
nogoList = readWpList(br, true);
|
||||||
|
params = br.readLine();
|
||||||
br.close();
|
br.close();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
AppLogger.log(AppLogger.formatThrowable(e));
|
AppLogger.log(AppLogger.formatThrowable(e));
|
||||||
|
|
@ -494,6 +499,15 @@ public class BRouterView extends View {
|
||||||
rc.localFunction = profilePath;
|
rc.localFunction = profilePath;
|
||||||
rc.turnInstructionMode = cor.getTurnInstructionMode();
|
rc.turnInstructionMode = cor.getTurnInstructionMode();
|
||||||
|
|
||||||
|
if (params != null && params.length() > 2) {
|
||||||
|
try {
|
||||||
|
Map<String, String> profileParamsCollection = null;
|
||||||
|
RoutingParamCollector routingParamCollector = new RoutingParamCollector();
|
||||||
|
profileParamsCollection = routingParamCollector.getUrlParams(params);
|
||||||
|
routingParamCollector.setProfileParams(rc, profileParamsCollection);
|
||||||
|
} catch (Exception e) {}
|
||||||
|
}
|
||||||
|
|
||||||
int plain_distance = 0;
|
int plain_distance = 0;
|
||||||
int maxlon = Integer.MIN_VALUE;
|
int maxlon = Integer.MIN_VALUE;
|
||||||
int minlon = Integer.MAX_VALUE;
|
int minlon = Integer.MAX_VALUE;
|
||||||
|
|
|
||||||
|
|
@ -100,11 +100,19 @@ public class BRouterWorker {
|
||||||
}
|
}
|
||||||
routingParamCollector.setParams(rc, waypoints, theParams);
|
routingParamCollector.setParams(rc, waypoints, theParams);
|
||||||
|
|
||||||
if (params.containsKey("extraParams")) {
|
Map<String, String> profileParamsCollection = null;
|
||||||
Map<String, String> profileparams = null;
|
|
||||||
try {
|
try {
|
||||||
profileparams = routingParamCollector.getUrlParams(params.getString("extraParams"));
|
if (profileParams != null) {
|
||||||
routingParamCollector.setProfileParams(rc, profileparams);
|
profileParamsCollection = routingParamCollector.getUrlParams(profileParams);
|
||||||
|
routingParamCollector.setProfileParams(rc, profileParamsCollection);
|
||||||
|
}
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
|
if (params.containsKey("extraParams")) {
|
||||||
|
try {
|
||||||
|
profileParamsCollection = routingParamCollector.getUrlParams(params.getString("extraParams"));
|
||||||
|
routingParamCollector.setProfileParams(rc, profileParamsCollection);
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
|
|
@ -213,6 +221,14 @@ public class BRouterWorker {
|
||||||
bw.write("\n");
|
bw.write("\n");
|
||||||
writeWPList(bw, waypoints);
|
writeWPList(bw, waypoints);
|
||||||
writeWPList(bw, rc.nogopoints);
|
writeWPList(bw, rc.nogopoints);
|
||||||
|
if (rc.keyValues != null) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (Map.Entry<String, String> e : rc.keyValues.entrySet()) {
|
||||||
|
sb.append(sb.length()>0 ? "&" : "").append(e.getKey()).append("=").append(e.getValue());
|
||||||
|
}
|
||||||
|
bw.write(sb.toString());
|
||||||
|
bw.write("\n");
|
||||||
|
}
|
||||||
bw.close();
|
bw.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue