Add testcase for param override

This commit is contained in:
Manuel Fuhr 2022-10-25 07:13:56 +02:00
parent eba0b18689
commit 15df3d392d
2 changed files with 95 additions and 5 deletions

View file

@ -7,6 +7,7 @@ import org.junit.Test;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class RoutingEngineTest {
@ -22,22 +23,36 @@ public class RoutingEngineTest {
@Test
public void routeCrossingSegmentBorder() {
String msg = calcRoute(8.720897, 50.002515, 8.723658, 49.997510, "testtrack");
String msg = calcRoute(8.720897, 50.002515, 8.723658, 49.997510, "testtrack", new RoutingContext());
// error message from router?
Assert.assertNull("routing failed: " + msg, msg);
// if the track didn't change, we expect the first alternative also
File a1 = new File(workingDir, "testtrack1.gpx");
Assert.assertTrue("result content missmatch", a1.exists());
a1.deleteOnExit();
Assert.assertTrue("result content mismatch", a1.exists());
}
@Test
public void routeDestinationPointFarOff() {
String msg = calcRoute(8.720897, 50.002515, 16.723658, 49.997510, "notrack");
String msg = calcRoute(8.720897, 50.002515, 16.723658, 49.997510, "notrack", new RoutingContext());
Assert.assertTrue(msg, msg != null && msg.contains("not found"));
}
private String calcRoute(double flon, double flat, double tlon, double tlat, String trackname) {
@Test
public void overrideParam() {
RoutingContext rctx = new RoutingContext();
rctx.keyValues = new HashMap<>();
rctx.keyValues.put("avoid_unsafe", "1.0");
String msg = calcRoute(8.723037, 50.000491, 8.712737, 50.002899, "paramTrack", rctx);
Assert.assertNull("routing failed: " + msg, msg);
File trackFile = new File(workingDir, "paramTrack1.gpx");
trackFile.deleteOnExit();
Assert.assertTrue("result content mismatch", trackFile.exists());
}
private String calcRoute(double flon, double flat, double tlon, double tlat, String trackname, RoutingContext rctx) {
String wd = workingDir.getAbsolutePath();
List<OsmNodeNamed> wplist = new ArrayList<>();
@ -54,7 +69,6 @@ public class RoutingEngineTest {
n.ilat = 90000000 + (int) (tlat * 1000000 + 0.5);
wplist.add(n);
RoutingContext rctx = new RoutingContext();
rctx.localFunction = wd + "/../../../../misc/profiles2/trekking.brf";
RoutingEngine re = new RoutingEngine(

View file

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- track-length = 1902 filtered ascend = 0 plain-ascend = 0 cost=2753 energy=.0kwh time=5m 9s -->
<gpx
xmlns="http://www.topografix.com/GPX/1/1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
creator="BRouter-1.6.3" version="1.1">
<trk>
<name>brouter_trekking_0</name>
<trkseg>
<trkpt lon="8.723027" lat="50.000499"></trkpt>
<trkpt lon="8.723285" lat="50.000610"></trkpt>
<trkpt lon="8.724003" lat="50.000939"></trkpt>
<trkpt lon="8.724437" lat="50.000856"></trkpt>
<trkpt lon="8.724590" lat="50.000810"></trkpt>
<trkpt lon="8.724778" lat="50.000741"></trkpt>
<trkpt lon="8.725133" lat="50.001318"></trkpt>
<trkpt lon="8.725379" lat="50.001518"></trkpt>
<trkpt lon="8.725365" lat="50.001683"></trkpt>
<trkpt lon="8.725388" lat="50.001830"></trkpt>
<trkpt lon="8.725421" lat="50.001903"></trkpt>
<trkpt lon="8.725492" lat="50.002032"></trkpt>
<trkpt lon="8.725642" lat="50.002152"></trkpt>
<trkpt lon="8.725847" lat="50.002262"></trkpt>
<trkpt lon="8.725994" lat="50.002570"></trkpt>
<trkpt lon="8.726143" lat="50.002754"></trkpt>
<trkpt lon="8.726166" lat="50.002864"></trkpt>
<trkpt lon="8.725143" lat="50.002880"></trkpt>
<trkpt lon="8.724635" lat="50.002851"></trkpt>
<trkpt lon="8.723968" lat="50.002840"></trkpt>
<trkpt lon="8.723534" lat="50.002821"></trkpt>
<trkpt lon="8.722486" lat="50.002697"></trkpt>
<trkpt lon="8.721892" lat="50.002631"></trkpt>
<trkpt lon="8.721836" lat="50.002624"></trkpt>
<trkpt lon="8.721209" lat="50.002553"></trkpt>
<trkpt lon="8.721118" lat="50.002538"></trkpt>
<trkpt lon="8.721021" lat="50.002493"></trkpt>
<trkpt lon="8.720994" lat="50.002509"></trkpt>
<trkpt lon="8.720960" lat="50.002518"></trkpt>
<trkpt lon="8.720888" lat="50.002517"></trkpt>
<trkpt lon="8.720853" lat="50.002586"></trkpt>
<trkpt lon="8.720782" lat="50.002704"></trkpt>
<trkpt lon="8.720554" lat="50.002937"></trkpt>
<trkpt lon="8.720469" lat="50.003004"></trkpt>
<trkpt lon="8.718899" lat="50.003724"></trkpt>
<trkpt lon="8.718254" lat="50.004051"></trkpt>
<trkpt lon="8.718123" lat="50.004087"></trkpt>
<trkpt lon="8.717543" lat="50.004244"></trkpt>
<trkpt lon="8.717181" lat="50.004357"></trkpt>
<trkpt lon="8.716729" lat="50.004515"></trkpt>
<trkpt lon="8.716463" lat="50.004600"></trkpt>
<trkpt lon="8.715713" lat="50.004799"></trkpt>
<trkpt lon="8.715490" lat="50.004843"></trkpt>
<trkpt lon="8.714977" lat="50.004918"></trkpt>
<trkpt lon="8.714539" lat="50.005012"></trkpt>
<trkpt lon="8.713784" lat="50.005136"></trkpt>
<trkpt lon="8.713582" lat="50.005177"></trkpt>
<trkpt lon="8.713316" lat="50.005086"></trkpt>
<trkpt lon="8.713067" lat="50.005001"></trkpt>
<trkpt lon="8.712848" lat="50.004896"></trkpt>
<trkpt lon="8.712781" lat="50.004859"></trkpt>
<trkpt lon="8.712667" lat="50.004765"></trkpt>
<trkpt lon="8.712563" lat="50.004683"></trkpt>
<trkpt lon="8.712154" lat="50.004321"></trkpt>
<trkpt lon="8.712066" lat="50.004245"></trkpt>
<trkpt lon="8.713422" lat="50.003599"></trkpt>
<trkpt lon="8.713452" lat="50.003572"></trkpt>
<trkpt lon="8.713592" lat="50.003347"></trkpt>
<trkpt lon="8.713620" lat="50.003326"></trkpt>
<trkpt lon="8.713956" lat="50.003142"></trkpt>
<trkpt lon="8.713468" lat="50.002781"></trkpt>
<trkpt lon="8.713293" lat="50.002684"></trkpt>
<trkpt lon="8.712770" lat="50.002929"></trkpt>
</trkseg>
</trk>
</gpx>