use of get elevation in app
This commit is contained in:
parent
3c5ac660bf
commit
40b4794573
2 changed files with 119 additions and 93 deletions
|
@ -6,7 +6,6 @@ import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
import android.os.RemoteException;
|
import android.os.RemoteException;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
@ -24,6 +23,7 @@ import java.util.List;
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
import btools.router.OsmNodeNamed;
|
import btools.router.OsmNodeNamed;
|
||||||
|
import btools.router.RoutingEngine;
|
||||||
|
|
||||||
public class BRouterService extends Service {
|
public class BRouterService extends Service {
|
||||||
|
|
||||||
|
@ -39,6 +39,15 @@ public class BRouterService extends Service {
|
||||||
|
|
||||||
BRouterWorker worker = new BRouterWorker();
|
BRouterWorker worker = new BRouterWorker();
|
||||||
|
|
||||||
|
for (String key : params.keySet()) {
|
||||||
|
// Log.d("BS", "income " + key + " = " + params.get(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
int engineMode = 0;
|
||||||
|
if (params.containsKey("engineMode")) {
|
||||||
|
engineMode = params.getInt("engineMode", 0);
|
||||||
|
}
|
||||||
|
|
||||||
// get base dir from private file
|
// get base dir from private file
|
||||||
String baseDir = null;
|
String baseDir = null;
|
||||||
InputStream configInput = null;
|
InputStream configInput = null;
|
||||||
|
@ -56,14 +65,15 @@ public class BRouterService extends Service {
|
||||||
}
|
}
|
||||||
worker.baseDir = baseDir;
|
worker.baseDir = baseDir;
|
||||||
worker.segmentDir = new File(baseDir, "brouter/segments4");
|
worker.segmentDir = new File(baseDir, "brouter/segments4");
|
||||||
|
String errMsg = null;
|
||||||
|
|
||||||
|
if (engineMode == RoutingEngine.BROUTER_ENGINEMODE_ROUTING) {
|
||||||
String remoteProfile = params.getString("remoteProfile", null);
|
String remoteProfile = params.getString("remoteProfile", null);
|
||||||
|
|
||||||
if (remoteProfile == null) {
|
if (remoteProfile == null) {
|
||||||
remoteProfile = checkForTestDummy(baseDir);
|
remoteProfile = checkForTestDummy(baseDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
String errMsg = null;
|
|
||||||
if (remoteProfile != null) {
|
if (remoteProfile != null) {
|
||||||
errMsg = getConfigForRemoteProfile(worker, baseDir, remoteProfile);
|
errMsg = getConfigForRemoteProfile(worker, baseDir, remoteProfile);
|
||||||
} else if (params.containsKey("profile")) {
|
} else if (params.containsKey("profile")) {
|
||||||
|
@ -83,7 +93,9 @@ public class BRouterService extends Service {
|
||||||
} else {
|
} else {
|
||||||
errMsg = getConfigFromMode(worker, baseDir, params.getString("v"), params.getString("fast"));
|
errMsg = getConfigFromMode(worker, baseDir, params.getString("v"), params.getString("fast"));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
worker.profilePath = baseDir + "/brouter/profiles2/dummy.brf";
|
||||||
|
}
|
||||||
if (errMsg != null) {
|
if (errMsg != null) {
|
||||||
return errMsg;
|
return errMsg;
|
||||||
}
|
}
|
||||||
|
@ -121,7 +133,7 @@ public class BRouterService extends Service {
|
||||||
try {
|
try {
|
||||||
String modesFile = baseDir + "/brouter/modes/serviceconfig.dat";
|
String modesFile = baseDir + "/brouter/modes/serviceconfig.dat";
|
||||||
br = new BufferedReader(new FileReader(modesFile));
|
br = new BufferedReader(new FileReader(modesFile));
|
||||||
for (;;) {
|
for (; ; ) {
|
||||||
String line = br.readLine();
|
String line = br.readLine();
|
||||||
if (line == null)
|
if (line == null)
|
||||||
break;
|
break;
|
||||||
|
@ -244,7 +256,7 @@ public class BRouterService extends Service {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
try {
|
try {
|
||||||
br = new BufferedReader(new FileReader(testdummy));
|
br = new BufferedReader(new FileReader(testdummy));
|
||||||
for (;;) {
|
for (; ; ) {
|
||||||
String line = br.readLine();
|
String line = br.readLine();
|
||||||
if (line == null)
|
if (line == null)
|
||||||
break;
|
break;
|
||||||
|
@ -290,7 +302,6 @@ public class BRouterService extends Service {
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void onStart(Intent intent, int startId) {
|
public void onStart(Intent intent, int startId) {
|
||||||
Log.d(getClass().getSimpleName(), "onStart()");
|
|
||||||
handleStart(intent, startId);
|
handleStart(intent, startId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,12 @@ public class BRouterWorker {
|
||||||
public String profileParams;
|
public String profileParams;
|
||||||
|
|
||||||
public String getTrackFromParams(Bundle params) {
|
public String getTrackFromParams(Bundle params) {
|
||||||
|
|
||||||
|
int engineMode = 0;
|
||||||
|
if (params.containsKey("engineMode")) {
|
||||||
|
engineMode = params.getInt("engineMode", 0);
|
||||||
|
}
|
||||||
|
|
||||||
String pathToFileResult = params.getString("pathToFileResult");
|
String pathToFileResult = params.getString("pathToFileResult");
|
||||||
|
|
||||||
if (pathToFileResult != null) {
|
if (pathToFileResult != null) {
|
||||||
|
@ -97,7 +103,7 @@ public class BRouterWorker {
|
||||||
waypoints = readPositions(params);
|
waypoints = readPositions(params);
|
||||||
}
|
}
|
||||||
if (params.containsKey("lonlats")) {
|
if (params.containsKey("lonlats")) {
|
||||||
waypoints = readLonlats(params);
|
waypoints = readLonlats(params, engineMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (waypoints == null) return "no pts ";
|
if (waypoints == null) return "no pts ";
|
||||||
|
@ -141,11 +147,6 @@ public class BRouterWorker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int engineMode = 0;
|
|
||||||
if (params.containsKey("engineMode")) {
|
|
||||||
engineMode = params.getInt("engineMode", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
writeTimeoutData(rc);
|
writeTimeoutData(rc);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -155,6 +156,7 @@ public class BRouterWorker {
|
||||||
cr.quite = true;
|
cr.quite = true;
|
||||||
cr.doRun(maxRunningTime);
|
cr.doRun(maxRunningTime);
|
||||||
|
|
||||||
|
if (engineMode == RoutingEngine.BROUTER_ENGINEMODE_ROUTING) {
|
||||||
// store new reference track if any
|
// store new reference track if any
|
||||||
// (can exist for timed-out search)
|
// (can exist for timed-out search)
|
||||||
if (cr.getFoundRawTrack() != null) {
|
if (cr.getFoundRawTrack() != null) {
|
||||||
|
@ -212,6 +214,12 @@ public class BRouterWorker {
|
||||||
return "error writing file: " + e;
|
return "error writing file: " + e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else { // get other infos
|
||||||
|
if (cr.getErrorMessage() != null) {
|
||||||
|
return cr.getErrorMessage();
|
||||||
|
}
|
||||||
|
return cr.getFoundInfo();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,25 +241,31 @@ public class BRouterWorker {
|
||||||
wplist.add(n);
|
wplist.add(n);
|
||||||
}
|
}
|
||||||
if (wplist.get(0).name.startsWith("via")) wplist.get(0).name = "from";
|
if (wplist.get(0).name.startsWith("via")) wplist.get(0).name = "from";
|
||||||
if (wplist.get(wplist.size() - 1).name.startsWith("via")) wplist.get(wplist.size() - 1).name = "to";
|
if (wplist.get(wplist.size() - 1).name.startsWith("via"))
|
||||||
|
wplist.get(wplist.size() - 1).name = "to";
|
||||||
|
|
||||||
return wplist;
|
return wplist;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<OsmNodeNamed> readLonlats(Bundle params) {
|
private List<OsmNodeNamed> readLonlats(Bundle params, int mode) {
|
||||||
List<OsmNodeNamed> wplist = new ArrayList<OsmNodeNamed>();
|
List<OsmNodeNamed> wplist = new ArrayList<OsmNodeNamed>();
|
||||||
|
|
||||||
String lonLats = params.getString("lonlats");
|
String lonLats = params.getString("lonlats");
|
||||||
if (lonLats == null) throw new IllegalArgumentException("lonlats parameter not set");
|
if (lonLats == null) throw new IllegalArgumentException("lonlats parameter not set");
|
||||||
|
|
||||||
String[] coords = lonLats.split("\\|");
|
String[] coords;
|
||||||
|
if (mode == 0) {
|
||||||
|
coords = lonLats.split("\\|");
|
||||||
if (coords.length < 2)
|
if (coords.length < 2)
|
||||||
throw new IllegalArgumentException("we need two lat/lon points at least!");
|
throw new IllegalArgumentException("we need two lat/lon points at least!");
|
||||||
|
} else {
|
||||||
|
coords = new String[1];
|
||||||
|
coords[0] = lonLats;
|
||||||
|
}
|
||||||
for (int i = 0; i < coords.length; i++) {
|
for (int i = 0; i < coords.length; i++) {
|
||||||
String[] lonLat = coords[i].split(",");
|
String[] lonLat = coords[i].split(",");
|
||||||
if (lonLat.length < 2)
|
if (lonLat.length < 2)
|
||||||
throw new IllegalArgumentException("we need two lat/lon points at least!");
|
throw new IllegalArgumentException("we need a lat and lon point at least!");
|
||||||
wplist.add(readPosition(lonLat[0], lonLat[1], "via" + i));
|
wplist.add(readPosition(lonLat[0], lonLat[1], "via" + i));
|
||||||
if (lonLat.length > 2) {
|
if (lonLat.length > 2) {
|
||||||
if (lonLat[2].equals("d")) {
|
if (lonLat[2].equals("d")) {
|
||||||
|
@ -263,7 +277,8 @@ public class BRouterWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wplist.get(0).name.startsWith("via")) wplist.get(0).name = "from";
|
if (wplist.get(0).name.startsWith("via")) wplist.get(0).name = "from";
|
||||||
if (wplist.get(wplist.size() - 1).name.startsWith("via")) wplist.get(wplist.size() - 1).name = "to";
|
if (wplist.get(wplist.size() - 1).name.startsWith("via"))
|
||||||
|
wplist.get(wplist.size() - 1).name = "to";
|
||||||
|
|
||||||
return wplist;
|
return wplist;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue