updated output for command line
This commit is contained in:
parent
c47444e0f8
commit
ad3db9c004
1 changed files with 64 additions and 16 deletions
|
@ -199,27 +199,63 @@ public class RoutingEngine extends Thread {
|
||||||
messageList.add(track.message);
|
messageList.add(track.message);
|
||||||
track.messageList = messageList;
|
track.messageList = messageList;
|
||||||
if (outfileBase != null) {
|
if (outfileBase != null) {
|
||||||
String filename = outfileBase + i + ".gpx";
|
String filename = outfileBase + i + "." + routingContext.outputFormat;
|
||||||
OsmTrack oldTrack = new OsmTrack();
|
OsmTrack oldTrack = null;
|
||||||
oldTrack.readGpx(filename);
|
switch (routingContext.outputFormat) {
|
||||||
if (track.equalsTrack(oldTrack)) {
|
case "gpx":
|
||||||
|
oldTrack = new FormatGpx(routingContext).read(filename);
|
||||||
|
break;
|
||||||
|
case "geojson": // read only gpx at the moment
|
||||||
|
case "json":
|
||||||
|
// oldTrack = new FormatJson(routingContext).read(filename);
|
||||||
|
break;
|
||||||
|
case "kml":
|
||||||
|
// oldTrack = new FormatJson(routingContext).read(filename);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (oldTrack != null && track.equalsTrack(oldTrack)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
oldTrack = null;
|
oldTrack = null;
|
||||||
track.exportWaypoints = routingContext.exportWaypoints;
|
track.exportWaypoints = routingContext.exportWaypoints;
|
||||||
// doesn't work at the moment
|
filename = outfileBase + i + "." + routingContext.outputFormat;
|
||||||
// use routingContext.outputFormat
|
switch (routingContext.outputFormat) {
|
||||||
track.writeGpx(filename);
|
case "gpx":
|
||||||
|
outputMessage = new FormatGpx(routingContext).format(track);
|
||||||
|
break;
|
||||||
|
case "geojson":
|
||||||
|
case "json":
|
||||||
|
outputMessage = new FormatJson(routingContext).format(track);
|
||||||
|
break;
|
||||||
|
case "kml":
|
||||||
|
outputMessage = new FormatKml(routingContext).format(track);
|
||||||
|
break;
|
||||||
|
case "csv":
|
||||||
|
default:
|
||||||
|
outputMessage = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (outputMessage != null) {
|
||||||
|
File out = new File(filename);
|
||||||
|
FileWriter fw = new FileWriter(filename);
|
||||||
|
fw.write(outputMessage);
|
||||||
|
fw.close();
|
||||||
|
outputMessage = null;
|
||||||
|
}
|
||||||
|
|
||||||
foundTrack = track;
|
foundTrack = track;
|
||||||
alternativeIndex = i;
|
alternativeIndex = i;
|
||||||
outfile = filename;
|
outfile = filename;
|
||||||
} else {
|
} else {
|
||||||
if (i == routingContext.getAlternativeIdx(0, 3)) {
|
if (i == routingContext.getAlternativeIdx(0, 3)) {
|
||||||
if ("CSV".equals(System.getProperty("reportFormat"))) {
|
if ("CSV".equals(System.getProperty("reportFormat"))) {
|
||||||
track.dumpMessages(null, routingContext);
|
String filename = outfileBase + i + ".csv";
|
||||||
|
new FormatCsv(routingContext).write(filename, track);
|
||||||
} else {
|
} else {
|
||||||
if (!quite) {
|
if (!quite) {
|
||||||
System.out.println(track.formatAsGpx());
|
System.out.println(new FormatGpx(routingContext).format(track));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foundTrack = track;
|
foundTrack = track;
|
||||||
|
@ -229,7 +265,7 @@ public class RoutingEngine extends Thread {
|
||||||
}
|
}
|
||||||
if (logfileBase != null) {
|
if (logfileBase != null) {
|
||||||
String logfilename = logfileBase + i + ".csv";
|
String logfilename = logfileBase + i + ".csv";
|
||||||
track.dumpMessages(logfilename, routingContext);
|
new FormatCsv(routingContext).write(logfilename, track);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -308,15 +344,27 @@ public class RoutingEngine extends Thread {
|
||||||
OsmNodeNamed n = new OsmNodeNamed(listOne.get(0).crosspoint);
|
OsmNodeNamed n = new OsmNodeNamed(listOne.get(0).crosspoint);
|
||||||
n.selev = startNode != null ? startNode.getSElev() : Short.MIN_VALUE;
|
n.selev = startNode != null ? startNode.getSElev() : Short.MIN_VALUE;
|
||||||
|
|
||||||
// doesn't work at the moment
|
switch (routingContext.outputFormat) {
|
||||||
// use routingContext.outputFormat
|
case "gpx":
|
||||||
outputMessage = OsmTrack.formatAsGpxWaypoint(n);
|
outputMessage = new FormatGpx(routingContext).formatAsWaypoint(n);
|
||||||
|
break;
|
||||||
|
case "geojson":
|
||||||
|
case "json":
|
||||||
|
outputMessage = new FormatJson(routingContext).formatAsWaypoint(n);
|
||||||
|
break;
|
||||||
|
case "kml":
|
||||||
|
case "csv":
|
||||||
|
default:
|
||||||
|
outputMessage = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (outfileBase != null) {
|
if (outfileBase != null) {
|
||||||
String filename = outfileBase + ".gpx";
|
String filename = outfileBase + "." + routingContext.outputFormat;
|
||||||
File out = new File(filename);
|
File out = new File(filename);
|
||||||
FileWriter fw = new FileWriter(filename);
|
FileWriter fw = new FileWriter(filename);
|
||||||
fw.write(outputMessage);
|
fw.write(outputMessage);
|
||||||
fw.close();
|
fw.close();
|
||||||
|
outputMessage = null;
|
||||||
}
|
}
|
||||||
long endTime = System.currentTimeMillis();
|
long endTime = System.currentTimeMillis();
|
||||||
logInfo("execution time = " + (endTime - startTime) / 1000. + " seconds");
|
logInfo("execution time = " + (endTime - startTime) / 1000. + " seconds");
|
||||||
|
|
Loading…
Reference in a new issue