Compare commits

..

No commits in common. "e03183559214fc413aaf589ec2c39e7f5818cf4a" and "063efcc3e1469d05ebcd454f725e981a4d5e6722" have entirely different histories.

11 changed files with 26 additions and 107 deletions

View File

@ -197,28 +197,25 @@ public class FormatGpx extends Formatter {
for (int i = 0; i <= t.pois.size() - 1; i++) {
OsmNodeNamed poi = t.pois.get(i);
formatWaypointGpx(sb, poi, "poi");
formatWaypointGpx(sb, poi);
}
if (t.exportWaypoints) {
for (int i = 0; i <= t.matchedWaypoints.size() - 1; i++) {
MatchedWaypoint wt = t.matchedWaypoints.get(i);
sb.append(" <wpt lon=\"").append(formatILon(wt.waypoint.ilon)).append("\" lat=\"")
.append(formatILat(wt.waypoint.ilat)).append("\">\n")
.append(" <name>").append(StringUtils.escapeXml10(wt.name)).append("</name>\n");
if (i == 0) {
formatWaypointGpx(sb, wt, "from");
sb.append(" <type>from</type>\n");
} else if (i == t.matchedWaypoints.size() - 1) {
formatWaypointGpx(sb, wt, "to");
sb.append(" <type>to</type>\n");
} else {
formatWaypointGpx(sb, wt, "via");
sb.append(" <type>via</type>\n");
}
sb.append(" </wpt>\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(" <trk>\n");
if (turnInstructionMode == 9
|| turnInstructionMode == 2
@ -457,7 +454,7 @@ public class FormatGpx extends Formatter {
StringWriter sw = new StringWriter(8192);
BufferedWriter bw = new BufferedWriter(sw);
formatGpxHeader(bw);
formatWaypointGpx(bw, n, null);
formatWaypointGpx(bw, n);
formatGpxFooter(bw);
bw.close();
sw.close();
@ -480,7 +477,7 @@ public class FormatGpx extends Formatter {
sb.append("</gpx>\n");
}
public void formatWaypointGpx(BufferedWriter sb, OsmNodeNamed n, String type) throws IOException {
public void formatWaypointGpx(BufferedWriter sb, OsmNodeNamed n) throws IOException {
sb.append(" <wpt lon=\"").append(formatILon(n.ilon)).append("\" lat=\"")
.append(formatILat(n.ilat)).append("\">");
if (n.getSElev() != Short.MIN_VALUE) {
@ -492,24 +489,6 @@ public class FormatGpx extends Formatter {
if (n.nodeDescription != null && rc != null) {
sb.append("<desc>").append(rc.expctxWay.getKeyValueDescription(false, n.nodeDescription)).append("</desc>");
}
if (type != null) {
sb.append("<type>").append(type).append("</type>");
}
sb.append("</wpt>\n");
}
public void formatWaypointGpx(BufferedWriter sb, MatchedWaypoint wp, String type) throws IOException {
sb.append(" <wpt lon=\"").append(formatILon(wp.waypoint.ilon)).append("\" lat=\"")
.append(formatILat(wp.waypoint.ilat)).append("\">");
if (wp.waypoint.getSElev() != Short.MIN_VALUE) {
sb.append("<ele>").append("" + wp.waypoint.getElev()).append("</ele>");
}
if (wp.name != null) {
sb.append("<name>").append(StringUtils.escapeXml10(wp.name)).append("</name>");
}
if (type != null) {
sb.append("<type>").append(type).append("</type>");
}
sb.append("</wpt>\n");
}

View File

@ -126,7 +126,7 @@ public class FormatJson extends Formatter {
sb.append(" ]\n");
sb.append(" }\n");
if (t.exportWaypoints || t.exportCorrectedWaypoints || !t.pois.isEmpty()) {
if (t.exportWaypoints || !t.pois.isEmpty()) {
sb.append(" },\n");
for (int i = 0; i <= t.pois.size() - 1; i++) {
OsmNodeNamed poi = t.pois.get(i);
@ -137,7 +137,6 @@ 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) {
@ -156,19 +155,6 @@ 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");
}

View File

@ -43,7 +43,7 @@ public class FormatKml extends Formatter {
sb.append(" </LineString>\n");
sb.append(" </Placemark>\n");
sb.append(" </Folder>\n");
if (t.exportWaypoints || t.exportCorrectedWaypoints || !t.pois.isEmpty()) {
if (t.exportWaypoints || !t.pois.isEmpty()) {
if (!t.pois.isEmpty()) {
sb.append(" <Folder>\n");
sb.append(" <name>poi</name>\n");
@ -62,10 +62,6 @@ 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(" </Document>\n");
sb.append("</kml>\n");
@ -83,16 +79,6 @@ public class FormatKml extends Formatter {
sb.append(" </Folder>\n");
}
private void createViaFolder(StringBuilder sb, String type, List<OsmNodeNamed> waypoints) {
sb.append(" <Folder>\n");
sb.append(" <name>" + type + "</name>\n");
for (int i = 0; i < waypoints.size(); i++) {
OsmNodeNamed wp = waypoints.get(i);
createPlaceMark(sb, wp.name, wp.ilat, wp.ilon);
}
sb.append(" </Folder>\n");
}
private void createPlaceMark(StringBuilder sb, String name, int ilat, int ilon) {
sb.append(" <Placemark>\n");
sb.append(" <name>" + StringUtils.escapeXml10(name) + "</name>\n");

View File

@ -61,9 +61,7 @@ public final class OsmTrack {
public String name = "unset";
protected List<MatchedWaypoint> matchedWaypoints;
protected List<OsmNodeNamed> correctedWaypoints;
public boolean exportWaypoints = false;
public boolean exportCorrectedWaypoints = false;
public void addNode(OsmPathElement node) {
nodes.add(0, node);

View File

@ -77,7 +77,6 @@ public final class RoutingContext {
public double waypointCatchingRange;
public boolean correctMisplacedViaPoints;
public double correctMisplacedViaPointsDistance;
public boolean continueStraight;
public boolean useDynamicDistance;
public boolean buildBeelineOnRange;
@ -127,8 +126,6 @@ public final class RoutingContext {
correctMisplacedViaPoints = 0.f != expctxGlobal.getVariableValue("correctMisplacedViaPoints", 1.f);
correctMisplacedViaPointsDistance = expctxGlobal.getVariableValue("correctMisplacedViaPointsDistance", 0.f); // 0 == don't use distance
continueStraight = 0.f != expctxGlobal.getVariableValue("continueStraight", 0.f);
// process tags not used in the profile (to have them in the data-tab)
processUnusedTags = 0.f != expctxGlobal.getVariableValue("processUnusedTags", 0.f);
@ -224,7 +221,6 @@ public final class RoutingContext {
public String outputFormat = "gpx";
public boolean exportWaypoints = false;
public boolean exportCorrectedWaypoints = false;
public OsmPrePath firstPrePath;

View File

@ -41,7 +41,6 @@ public class RoutingEngine extends Thread {
private boolean finished = false;
protected List<OsmNodeNamed> waypoints = null;
protected List<OsmNodeNamed> correctedWaypoints = null;
List<OsmNodeNamed> extraWaypoints = null;
protected List<MatchedWaypoint> matchedWaypoints;
private int linksProcessed = 0;
@ -263,7 +262,6 @@ 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":
@ -977,10 +975,6 @@ 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;
@ -1001,7 +995,7 @@ public class RoutingEngine extends Thread {
} else {
seg = searchTrack(matchedWaypoints.get(i), matchedWaypoints.get(i + 1), i == matchedWaypoints.size() - 2 ? nearbyTrack : null, refTracks[i]);
wptIndex = i;
if (routingContext.continueStraight) {
if (engineMode == BROUTER_ENGINEMODE_ROUNDTRIP) {
if (i < matchedWaypoints.size() - 2) {
OsmNode lastPoint = seg.containsNode(matchedWaypoints.get(i+1).node1) ? matchedWaypoints.get(i+1).node1 : matchedWaypoints.get(i+1).node2;
OsmNodeNamed nogo = new OsmNodeNamed(lastPoint);
@ -1036,7 +1030,6 @@ 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);
@ -1144,12 +1137,7 @@ public class RoutingEngine extends Thread {
indexfore++;
if (routingContext.correctMisplacedViaPointsDistance > 0 &&
wayDistance > routingContext.correctMisplacedViaPointsDistance) {
removeVoiceHintList.clear();
removeBackList.clear();
removeForeList.clear();
return false;
}
wayDistance > routingContext.correctMisplacedViaPointsDistance) break;
}
@ -1195,13 +1183,6 @@ 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;

View File

@ -227,8 +227,6 @@ 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")) {

View File

@ -101,8 +101,8 @@ repositories {
dependencies {
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation "androidx.constraintlayout:constraintlayout:2.2.1"
implementation 'androidx.work:work-runtime:2.10.0'
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation 'androidx.work:work-runtime:2.9.0'
implementation 'com.google.android.material:material:1.12.0'
implementation project(':brouter-mapaccess')
@ -115,7 +115,7 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
androidTestImplementation 'androidx.work:work-testing:2.10.0'
androidTestImplementation 'androidx.work:work-testing:2.9.0'
}
gradle.projectsEvaluated {

View File

@ -161,7 +161,6 @@ 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:

View File

@ -160,8 +160,8 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
} else if (url.startsWith(PROFILE_UPLOAD_URL)) {
if (getline.startsWith("OPTIONS")) {
// handle CORS preflight request (Safari)
String corsHeaders = "Access-Control-Allow-Methods: GET, POST\r\n"
+ "Access-Control-Allow-Headers: Content-Type\r\n";
String corsHeaders = "Access-Control-Allow-Methods: GET, POST\n"
+ "Access-Control-Allow-Headers: Content-Type\n";
writeHttpHeader(bw, "text/plain", null, corsHeaders, HTTP_STATUS_OK);
bw.flush();
return;
@ -220,7 +220,7 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
// no zip for this engineMode
encodings = null;
}
String headers = encodings == null || encodings.indexOf("gzip") < 0 ? null : "Content-Encoding: gzip\r\n";
String headers = encodings == null || encodings.indexOf("gzip") < 0 ? null : "Content-Encoding: gzip\n";
writeHttpHeader(bw, handler.getMimeType(), handler.getFileName(), headers, HTTP_STATUS_OK);
if (engineMode == RoutingEngine.BROUTER_ENGINEMODE_ROUTING ||
engineMode == RoutingEngine.BROUTER_ENGINEMODE_ROUNDTRIP) {
@ -407,17 +407,17 @@ public class RouteServer extends Thread implements Comparable<RouteServer> {
private static void writeHttpHeader(BufferedWriter bw, String mimeType, String fileName, String headers, String status) throws IOException {
// http-header
bw.write(String.format("HTTP/1.1 %s\r\n", status));
bw.write("Connection: close\r\n");
bw.write("Content-Type: " + mimeType + "; charset=utf-8\r\n");
bw.write(String.format("HTTP/1.1 %s\n", status));
bw.write("Connection: close\n");
bw.write("Content-Type: " + mimeType + "; charset=utf-8\n");
if (fileName != null) {
bw.write("Content-Disposition: attachment; filename=\"" + fileName + "\"\r\n");
bw.write("Content-Disposition: attachment; filename=\"" + fileName + "\"\n");
}
bw.write("Access-Control-Allow-Origin: *\r\n");
bw.write("Access-Control-Allow-Origin: *\n");
if (headers != null) {
bw.write(headers);
}
bw.write("\r\n");
bw.write("\n");
}
private static void cleanupThreadQueue(Queue<RouteServer> threadQueue) {

View File

@ -78,10 +78,6 @@ 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);