changes for engineMode 2
This commit is contained in:
parent
fcbaf598aa
commit
8a7fa9fa81
3 changed files with 30 additions and 11 deletions
|
@ -365,6 +365,10 @@ public class RoutingEngine extends Thread {
|
|||
fw.write(outputMessage);
|
||||
fw.close();
|
||||
outputMessage = null;
|
||||
} else {
|
||||
if (!quite && outputMessage != null) {
|
||||
System.out.println(outputMessage);
|
||||
}
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
logInfo("execution time = " + (endTime - startTime) / 1000. + " seconds");
|
||||
|
|
|
@ -30,6 +30,10 @@ public class BRouter {
|
|||
List<OsmNodeNamed> wplist = routingParamCollector.getWayPointList(lonlats);
|
||||
|
||||
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);
|
||||
|
||||
String exportName = null;
|
||||
|
@ -47,7 +51,7 @@ public class BRouter {
|
|||
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);
|
||||
if (re.getErrorMessage() != null) {
|
||||
System.out.println(re.getErrorMessage());
|
||||
|
|
|
@ -211,18 +211,29 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
|
|||
} else {
|
||||
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";
|
||||
writeHttpHeader(bw, handler.getMimeType(), handler.getFileName(), headers, HTTP_STATUS_OK);
|
||||
if (track != null) {
|
||||
if (headers != null) { // compressed
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
Writer w = new OutputStreamWriter(new GZIPOutputStream(baos), "UTF-8");
|
||||
w.write(handler.formatTrack(track));
|
||||
w.close();
|
||||
bw.flush();
|
||||
clientSocket.getOutputStream().write(baos.toByteArray());
|
||||
} else {
|
||||
bw.write(handler.formatTrack(track));
|
||||
if (engineMode == 0) {
|
||||
if (track != null) {
|
||||
if (headers != null) { // compressed
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
Writer w = new OutputStreamWriter(new GZIPOutputStream(baos), "UTF-8");
|
||||
w.write(handler.formatTrack(track));
|
||||
w.close();
|
||||
bw.flush();
|
||||
clientSocket.getOutputStream().write(baos.toByteArray());
|
||||
} else {
|
||||
bw.write(handler.formatTrack(track));
|
||||
}
|
||||
}
|
||||
} else if (engineMode == 2) {
|
||||
String s = cr.getFoundInfo();
|
||||
if (s != null) {
|
||||
bw.write(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue