changes for engineMode 2

This commit is contained in:
afischerdev 2023-11-21 13:26:05 +01:00
parent fcbaf598aa
commit 8a7fa9fa81
3 changed files with 30 additions and 11 deletions

View file

@ -365,6 +365,10 @@ public class RoutingEngine extends Thread {
fw.write(outputMessage); fw.write(outputMessage);
fw.close(); fw.close();
outputMessage = null; outputMessage = null;
} else {
if (!quite && outputMessage != null) {
System.out.println(outputMessage);
}
} }
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
logInfo("execution time = " + (endTime - startTime) / 1000. + " seconds"); logInfo("execution time = " + (endTime - startTime) / 1000. + " seconds");

View file

@ -30,6 +30,10 @@ public class BRouter {
List<OsmNodeNamed> wplist = routingParamCollector.getWayPointList(lonlats); List<OsmNodeNamed> wplist = routingParamCollector.getWayPointList(lonlats);
Map<String, String> params = routingParamCollector.getUrlParams(queryString); Map<String, String> params = routingParamCollector.getUrlParams(queryString);
int engineMode = 0;
if (params.containsKey("engineMode")) {
engineMode = Integer.parseInt(params.get("engineMode"));
}
routingParamCollector.setParams(rc, wplist, params); routingParamCollector.setParams(rc, wplist, params);
String exportName = null; String exportName = null;
@ -47,7 +51,7 @@ public class BRouter {
maxRunningTime = Integer.parseInt(sMaxRunningTime) * 1000; maxRunningTime = Integer.parseInt(sMaxRunningTime) * 1000;
} }
RoutingEngine re = new RoutingEngine(exportName, null, new File(args[0]), wplist, rc); RoutingEngine re = new RoutingEngine(exportName, null, new File(args[0]), wplist, rc, engineMode);
re.doRun(maxRunningTime); re.doRun(maxRunningTime);
if (re.getErrorMessage() != null) { if (re.getErrorMessage() != null) {
System.out.println(re.getErrorMessage()); System.out.println(re.getErrorMessage());

View file

@ -211,8 +211,13 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
} else { } else {
OsmTrack track = cr.getFoundTrack(); OsmTrack track = cr.getFoundTrack();
if (engineMode == 2) {
// no zip for this engineMode
encodings = null;
}
String headers = encodings == null || encodings.indexOf("gzip") < 0 ? null : "Content-Encoding: gzip\n"; String headers = encodings == null || encodings.indexOf("gzip") < 0 ? null : "Content-Encoding: gzip\n";
writeHttpHeader(bw, handler.getMimeType(), handler.getFileName(), headers, HTTP_STATUS_OK); writeHttpHeader(bw, handler.getMimeType(), handler.getFileName(), headers, HTTP_STATUS_OK);
if (engineMode == 0) {
if (track != null) { if (track != null) {
if (headers != null) { // compressed if (headers != null) { // compressed
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream();
@ -225,6 +230,12 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
bw.write(handler.formatTrack(track)); bw.write(handler.formatTrack(track));
} }
} }
} else if (engineMode == 2) {
String s = cr.getFoundInfo();
if (s != null) {
bw.write(s);
}
}
} }
bw.flush(); bw.flush();
} catch (Throwable e) { } catch (Throwable e) {