From 54a7ad6b9d55fe611722810945374c2ae70f3ac3 Mon Sep 17 00:00:00 2001 From: afischerdev Date: Wed, 2 Nov 2022 09:37:12 +0100 Subject: [PATCH] update lib part one --- .../main/java/btools/router/OsmNodeNamed.java | 1 + .../btools/mapaccess/MatchedWaypoint.java | 1 + .../btools/routingapp/IBRouterService.aidl | 7 ++++-- .../java/btools/routingapp/BRouterWorker.java | 23 +++++++++++++++++-- .../main/java/btools/server/RouteServer.java | 6 +++++ .../btools/server/request/ServerHandler.java | 7 ++++++ 6 files changed, 41 insertions(+), 4 deletions(-) diff --git a/brouter-core/src/main/java/btools/router/OsmNodeNamed.java b/brouter-core/src/main/java/btools/router/OsmNodeNamed.java index ff0b789..633d428 100644 --- a/brouter-core/src/main/java/btools/router/OsmNodeNamed.java +++ b/brouter-core/src/main/java/btools/router/OsmNodeNamed.java @@ -13,6 +13,7 @@ public class OsmNodeNamed extends OsmNode { public double radius; // radius of nogopoint (in meters) public double nogoWeight; // weight for nogopoint public boolean isNogo = false; + public boolean direct = false; // mark direct routing public OsmNodeNamed() { } diff --git a/brouter-mapaccess/src/main/java/btools/mapaccess/MatchedWaypoint.java b/brouter-mapaccess/src/main/java/btools/mapaccess/MatchedWaypoint.java index ccc2909..f084f3f 100644 --- a/brouter-mapaccess/src/main/java/btools/mapaccess/MatchedWaypoint.java +++ b/brouter-mapaccess/src/main/java/btools/mapaccess/MatchedWaypoint.java @@ -18,6 +18,7 @@ public final class MatchedWaypoint { public OsmNode waypoint; public String name; // waypoint name used in error messages public double radius; // distance in meter between waypoint and crosspoint + public boolean direct; // from this point go direct to next = beeline routing public boolean hasUpdate; diff --git a/brouter-routing-app/src/main/aidl/btools/routingapp/IBRouterService.aidl b/brouter-routing-app/src/main/aidl/btools/routingapp/IBRouterService.aidl index 97fccd0..c29ab16 100644 --- a/brouter-routing-app/src/main/aidl/btools/routingapp/IBRouterService.aidl +++ b/brouter-routing-app/src/main/aidl/btools/routingapp/IBRouterService.aidl @@ -20,6 +20,9 @@ interface IBRouterService { // "remoteProfile"--> (String), net-content of a profile. If remoteProfile != null, v+fast are ignored // // "lonlats" = lon,lat|... (unlimited list of lon,lat waypoints separated by |) + // variantes: lon,lat,d|... (from this point to the next do a direct line) + // lon,lat,name|... (route point has a name and should not be ignored) + // "straight" = idx1,idx2,.. (optional, minimum one value, index of a direct routing point in the waypoint list) // "nogos" = lon,lat,radius|... (optional, radius in meters) // "polylines" = lon,lat,lon,lat,...,weight|... (unlimited list of lon,lat and weight (optional), lists separated by |) // "polygons" = lon,lat,lon,lat,...,weight|... (unlimited list of lon,lat and weight (optional), lists separated by |) @@ -28,9 +31,9 @@ interface IBRouterService { // "exportWaypoints" = 1 to export them (optional, default is no export) // "pois" = lon,lat,name|... (optional) // "extraParams" = Bundle key=value list for a profile setup (like "profile:") - // "timode" = turnInstructionMode [0=none, 1=auto-choose, 2=locus-style, 3=osmand-style, 4=comment-style, 5=gpsies-style, 6=orux-style] default 0 + // "timode" = turnInstructionMode [0=none, 1=auto-choose, 2=locus-style, 3=osmand-style, 4=comment-style, 5=gpsies-style, 6=orux-style, 7=locus-new-style, 8=cruiser-stylem, 9=brouter-intern] default 0 // "heading" = angle (optional to give a route a start direction) - // "direction" = (deprecated) angle + // "direction" = angle (optional, used on recalculation, only used by Locus) // return null if all ok and no path given, the track if ok and path given, an error message if it was wrong // the resultas string when 'pathToFileResult' is null, this should be default when Android Q or later 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 82bfe64..43111cc 100644 --- a/brouter-routing-app/src/main/java/btools/routingapp/BRouterWorker.java +++ b/brouter-routing-app/src/main/java/btools/routingapp/BRouterWorker.java @@ -57,7 +57,7 @@ public class BRouterWorker { if ("osmand".equalsIgnoreCase(tiFormat)) { rc.turnInstructionMode = 3; } else if ("locus".equalsIgnoreCase(tiFormat)) { - rc.turnInstructionMode = 2; + rc.turnInstructionMode = 7; } } if (params.containsKey("timode")) { @@ -112,7 +112,19 @@ public class BRouterWorker { String key = tk2.nextToken(); if (tk2.hasMoreTokens()) { String value = tk2.nextToken(); - rc.keyValues.put(key, value); + if (key.equals("straight")) { + try { + String[] sa = value.split(","); + for ( int i = 0; i v) waypoints.get(v).direct = true; + } + } catch (Exception e) { + System.err.println("error " + e.getStackTrace()[0].getLineNumber() + " " + e.getStackTrace()[0] + "\n" +e); + } + } else { + rc.keyValues.put(key, value); + } } } } @@ -226,6 +238,13 @@ public class BRouterWorker { if (lonLat.length < 2) throw new IllegalArgumentException("we need two lat/lon points at least!"); wplist.add(readPosition(lonLat[0], lonLat[1], "via" + i)); + if (lonLat.length > 2) { + if (lonLat[2].equals("d")) { + wplist.get(wplist.size()-1).direct = true; + } else { + wplist.get(wplist.size()-1).name = lonLat[2]; + } + } } wplist.get(0).name = "from"; diff --git a/brouter-server/src/main/java/btools/server/RouteServer.java b/brouter-server/src/main/java/btools/server/RouteServer.java index 62c74e5..a40b864 100644 --- a/brouter-server/src/main/java/btools/server/RouteServer.java +++ b/brouter-server/src/main/java/btools/server/RouteServer.java @@ -218,6 +218,12 @@ public class RouteServer extends Thread implements Comparable { rc.keyValues = new HashMap(); } rc.keyValues.put(e.getKey().substring(8), e.getValue()); + } else if (e.getKey().equals("straight")) { + String[] sa = e.getValue().split(","); + for (int i = 0; i v) wplist.get(v).direct = true; + } } } cr = new RoutingEngine(null, null, serviceContext.segmentDir, wplist, rc); 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 2c3897c..73641be 100644 --- a/brouter-server/src/main/java/btools/server/request/ServerHandler.java +++ b/brouter-server/src/main/java/btools/server/request/ServerHandler.java @@ -95,6 +95,13 @@ public class ServerHandler extends RequestHandler { if (lonLat.length < 2) throw new IllegalArgumentException("we need two lat/lon points at least!"); wplist.add(readPosition(lonLat[0], lonLat[1], "via" + i)); + if (lonLat.length > 2) { + if (lonLat[2].equals("d")) { + wplist.get(wplist.size()-1).direct = true; + } else { + wplist.get(wplist.size()-1).name = lonLat[2]; + } + } } wplist.get(0).name = "from";