diff --git a/brouter-core/src/main/java/btools/router/FormatGpx.java b/brouter-core/src/main/java/btools/router/FormatGpx.java
index c652a0a..6f969d1 100644
--- a/brouter-core/src/main/java/btools/router/FormatGpx.java
+++ b/brouter-core/src/main/java/btools/router/FormatGpx.java
@@ -197,25 +197,28 @@ public class FormatGpx extends Formatter {
for (int i = 0; i <= t.pois.size() - 1; i++) {
OsmNodeNamed poi = t.pois.get(i);
- formatWaypointGpx(sb, poi);
+ formatWaypointGpx(sb, poi, "poi");
}
if (t.exportWaypoints) {
for (int i = 0; i <= t.matchedWaypoints.size() - 1; i++) {
MatchedWaypoint wt = t.matchedWaypoints.get(i);
- sb.append(" \n")
- .append(" ").append(StringUtils.escapeXml10(wt.name)).append("\n");
if (i == 0) {
- sb.append(" from\n");
+ formatWaypointGpx(sb, wt, "from");
} else if (i == t.matchedWaypoints.size() - 1) {
- sb.append(" to\n");
+ formatWaypointGpx(sb, wt, "to");
} else {
- sb.append(" via\n");
+ formatWaypointGpx(sb, wt, "via");
}
- sb.append(" \n");
}
}
+ if (t.exportCorrectedWaypoints && t.correctedWaypoints != null) {
+ for (int i = 0; i <= t.correctedWaypoints.size() - 1; i++) {
+ OsmNodeNamed n = t.correctedWaypoints.get(i);
+ formatWaypointGpx(sb, n, "via_corr");
+ }
+ }
+
sb.append(" \n");
if (turnInstructionMode == 9
|| turnInstructionMode == 2
@@ -454,7 +457,7 @@ public class FormatGpx extends Formatter {
StringWriter sw = new StringWriter(8192);
BufferedWriter bw = new BufferedWriter(sw);
formatGpxHeader(bw);
- formatWaypointGpx(bw, n);
+ formatWaypointGpx(bw, n, null);
formatGpxFooter(bw);
bw.close();
sw.close();
@@ -477,7 +480,7 @@ public class FormatGpx extends Formatter {
sb.append("\n");
}
- public void formatWaypointGpx(BufferedWriter sb, OsmNodeNamed n) throws IOException {
+ public void formatWaypointGpx(BufferedWriter sb, OsmNodeNamed n, String type) throws IOException {
sb.append(" ");
if (n.getSElev() != Short.MIN_VALUE) {
@@ -489,6 +492,24 @@ public class FormatGpx extends Formatter {
if (n.nodeDescription != null && rc != null) {
sb.append("").append(rc.expctxWay.getKeyValueDescription(false, n.nodeDescription)).append("");
}
+ if (type != null) {
+ sb.append("").append(type).append("");
+ }
+ sb.append("\n");
+ }
+
+ public void formatWaypointGpx(BufferedWriter sb, MatchedWaypoint wp, String type) throws IOException {
+ sb.append(" ");
+ if (wp.waypoint.getSElev() != Short.MIN_VALUE) {
+ sb.append("").append("" + wp.waypoint.getElev()).append("");
+ }
+ if (wp.name != null) {
+ sb.append("").append(StringUtils.escapeXml10(wp.name)).append("");
+ }
+ if (type != null) {
+ sb.append("").append(type).append("");
+ }
sb.append("\n");
}
diff --git a/brouter-core/src/main/java/btools/router/FormatJson.java b/brouter-core/src/main/java/btools/router/FormatJson.java
index 53f0b4a..c380fa4 100644
--- a/brouter-core/src/main/java/btools/router/FormatJson.java
+++ b/brouter-core/src/main/java/btools/router/FormatJson.java
@@ -126,7 +126,7 @@ public class FormatJson extends Formatter {
sb.append(" ]\n");
sb.append(" }\n");
- if (t.exportWaypoints || !t.pois.isEmpty()) {
+ if (t.exportWaypoints || t.exportCorrectedWaypoints || !t.pois.isEmpty()) {
sb.append(" },\n");
for (int i = 0; i <= t.pois.size() - 1; i++) {
OsmNodeNamed poi = t.pois.get(i);
@@ -137,6 +137,7 @@ public class FormatJson extends Formatter {
sb.append(" \n");
}
if (t.exportWaypoints) {
+ if (!t.pois.isEmpty()) sb.append(" ,\n");
for (int i = 0; i <= t.matchedWaypoints.size() - 1; i++) {
String type;
if (i == 0) {
@@ -155,6 +156,19 @@ public class FormatJson extends Formatter {
sb.append(" \n");
}
}
+ if (t.exportCorrectedWaypoints) {
+ if (t.exportWaypoints) sb.append(" ,\n");
+ for (int i = 0; i <= t.correctedWaypoints.size() - 1; i++) {
+ String type = "via_corr";
+
+ OsmNodeNamed wp = t.correctedWaypoints.get(i);
+ addFeature(sb, type, wp.name, wp.ilat, wp.ilon, wp.getSElev());
+ if (i < t.correctedWaypoints.size() - 1) {
+ sb.append(",");
+ }
+ sb.append(" \n");
+ }
+ }
} else {
sb.append(" }\n");
}
diff --git a/brouter-core/src/main/java/btools/router/FormatKml.java b/brouter-core/src/main/java/btools/router/FormatKml.java
index 5798c5c..79d1e08 100644
--- a/brouter-core/src/main/java/btools/router/FormatKml.java
+++ b/brouter-core/src/main/java/btools/router/FormatKml.java
@@ -43,7 +43,7 @@ public class FormatKml extends Formatter {
sb.append(" \n");
sb.append(" \n");
sb.append(" \n");
- if (t.exportWaypoints || !t.pois.isEmpty()) {
+ if (t.exportWaypoints || t.exportCorrectedWaypoints || !t.pois.isEmpty()) {
if (!t.pois.isEmpty()) {
sb.append(" \n");
sb.append(" poi\n");
@@ -62,6 +62,10 @@ public class FormatKml extends Formatter {
}
createFolder(sb, "end", t.matchedWaypoints.subList(size - 1, size));
}
+ if (t.exportCorrectedWaypoints) {
+ int size = t.correctedWaypoints.size();
+ createViaFolder(sb, "via_cor", t.correctedWaypoints.subList(0, size));
+ }
}
sb.append(" \n");
sb.append("\n");
@@ -79,6 +83,16 @@ public class FormatKml extends Formatter {
sb.append(" \n");
}
+ private void createViaFolder(StringBuilder sb, String type, List waypoints) {
+ sb.append(" \n");
+ sb.append(" " + type + "\n");
+ for (int i = 0; i < waypoints.size(); i++) {
+ OsmNodeNamed wp = waypoints.get(i);
+ createPlaceMark(sb, wp.name, wp.ilat, wp.ilon);
+ }
+ sb.append(" \n");
+ }
+
private void createPlaceMark(StringBuilder sb, String name, int ilat, int ilon) {
sb.append(" \n");
sb.append(" " + StringUtils.escapeXml10(name) + "\n");
diff --git a/brouter-core/src/main/java/btools/router/OsmTrack.java b/brouter-core/src/main/java/btools/router/OsmTrack.java
index ccc232a..b56a7df 100644
--- a/brouter-core/src/main/java/btools/router/OsmTrack.java
+++ b/brouter-core/src/main/java/btools/router/OsmTrack.java
@@ -61,7 +61,9 @@ public final class OsmTrack {
public String name = "unset";
protected List matchedWaypoints;
+ protected List correctedWaypoints;
public boolean exportWaypoints = false;
+ public boolean exportCorrectedWaypoints = false;
public void addNode(OsmPathElement node) {
nodes.add(0, node);
diff --git a/brouter-core/src/main/java/btools/router/RoutingContext.java b/brouter-core/src/main/java/btools/router/RoutingContext.java
index c1d63c5..792014c 100644
--- a/brouter-core/src/main/java/btools/router/RoutingContext.java
+++ b/brouter-core/src/main/java/btools/router/RoutingContext.java
@@ -224,6 +224,7 @@ public final class RoutingContext {
public String outputFormat = "gpx";
public boolean exportWaypoints = false;
+ public boolean exportCorrectedWaypoints = false;
public OsmPrePath firstPrePath;
diff --git a/brouter-core/src/main/java/btools/router/RoutingEngine.java b/brouter-core/src/main/java/btools/router/RoutingEngine.java
index e8c80b5..b86f4a0 100644
--- a/brouter-core/src/main/java/btools/router/RoutingEngine.java
+++ b/brouter-core/src/main/java/btools/router/RoutingEngine.java
@@ -41,6 +41,7 @@ public class RoutingEngine extends Thread {
private boolean finished = false;
protected List waypoints = null;
+ protected List correctedWaypoints = null;
List extraWaypoints = null;
protected List matchedWaypoints;
private int linksProcessed = 0;
@@ -262,6 +263,7 @@ public class RoutingEngine extends Thread {
}
oldTrack = null;
track.exportWaypoints = routingContext.exportWaypoints;
+ track.exportCorrectedWaypoints = routingContext.exportCorrectedWaypoints;
filename = outfileBase + i + "." + routingContext.outputFormat;
switch (routingContext.outputFormat) {
case "gpx":
@@ -975,6 +977,10 @@ public class RoutingEngine extends Thread {
hasDirectRouting = true;
}
}
+ for (MatchedWaypoint mwp : matchedWaypoints) {
+ //System.out.println(FormatGpx.getWaypoint(mwp.waypoint.ilon, mwp.waypoint.ilat, mwp.name, null));
+ //System.out.println(FormatGpx.getWaypoint(mwp.crosspoint.ilon, mwp.crosspoint.ilat, mwp.name+"_cp", null));
+ }
routingContext.hasDirectRouting = hasDirectRouting;
@@ -1030,6 +1036,7 @@ public class RoutingEngine extends Thread {
matchedWaypoints.get(matchedWaypoints.size() - 1).indexInTrack = totaltrack.nodes.size() - 1;
totaltrack.matchedWaypoints = matchedWaypoints;
+ totaltrack.correctedWaypoints = correctedWaypoints;
totaltrack.processVoiceHints(routingContext);
totaltrack.prepareSpeedProfile(routingContext);
@@ -1188,6 +1195,13 @@ public class RoutingEngine extends Thread {
setNewVoiceHint(t, last, lastJunctions, newJunction, newTarget);
+ if (correctedWaypoints == null) correctedWaypoints = new ArrayList<>();
+ OsmNodeNamed n = new OsmNodeNamed();
+ n.ilon = newJunction.getILon();
+ n.ilat = newJunction.getILat();
+ n.name = startWp.name + "_corr";
+ correctedWaypoints.add(n);
+
return true;
}
return false;
diff --git a/brouter-core/src/main/java/btools/router/RoutingParamCollector.java b/brouter-core/src/main/java/btools/router/RoutingParamCollector.java
index f239315..1bcc6ee 100644
--- a/brouter-core/src/main/java/btools/router/RoutingParamCollector.java
+++ b/brouter-core/src/main/java/btools/router/RoutingParamCollector.java
@@ -227,6 +227,8 @@ public class RoutingParamCollector {
}
} else if (key.equals("exportWaypoints")) {
rctx.exportWaypoints = (Integer.parseInt(value) == 1);
+ } else if (key.equals("exportCorrectedWaypoints")) {
+ rctx.exportCorrectedWaypoints = (Integer.parseInt(value) == 1);
} else if (key.equals("format")) {
rctx.outputFormat = ((String) value).toLowerCase();
} else if (key.equals("trackFormat")) {
diff --git a/brouter-routing-app/src/main/java/btools/routingapp/BRouterWorker.java b/brouter-routing-app/src/main/java/btools/routingapp/BRouterWorker.java
index 33ee802..437d136 100644
--- a/brouter-routing-app/src/main/java/btools/routingapp/BRouterWorker.java
+++ b/brouter-routing-app/src/main/java/btools/routingapp/BRouterWorker.java
@@ -161,6 +161,7 @@ public class BRouterWorker {
track = cr.getFoundTrack();
if (track != null) {
track.exportWaypoints = rc.exportWaypoints;
+ track.exportCorrectedWaypoints = rc.exportCorrectedWaypoints;
if (pathToFileResult == null) {
switch (writeFromat) {
case OUTPUT_FORMAT_KML:
diff --git a/brouter-server/src/main/java/btools/server/request/ServerHandler.java b/brouter-server/src/main/java/btools/server/request/ServerHandler.java
index 37ba145..fcb536c 100644
--- a/brouter-server/src/main/java/btools/server/request/ServerHandler.java
+++ b/brouter-server/src/main/java/btools/server/request/ServerHandler.java
@@ -78,6 +78,10 @@ public class ServerHandler extends RequestHandler {
if (exportWaypointsStr != null && Integer.parseInt(exportWaypointsStr) != 0) {
track.exportWaypoints = true;
}
+ exportWaypointsStr = params.get("exportCorrectedWaypoints");
+ if (exportWaypointsStr != null && Integer.parseInt(exportWaypointsStr) != 0) {
+ track.exportCorrectedWaypoints = true;
+ }
if (format == null || "gpx".equals(format)) {
result = new FormatGpx(rc).format(track);