Move testcases from brouter-server to their modules

This commit is contained in:
Manuel Fuhr 2022-10-23 10:11:12 +02:00
parent 93e8a81005
commit 3787076839
3 changed files with 3 additions and 6 deletions

View file

@ -0,0 +1,74 @@
package btools.router;
import java.util.*;
import org.junit.Assert;
import org.junit.Test;
import java.net.URL;
import java.io.File;
public class RoutingEngineTest {
private File workingDir;
@Test
public void routerTest() throws Exception {
URL resulturl = this.getClass().getResource("/testtrack0.gpx");
Assert.assertTrue("reference result not found: ", resulturl != null);
File resultfile = new File(resulturl.getFile());
workingDir = resultfile.getParentFile();
String msg;
// first test: route within dreiech test-map crossing tile border
msg = calcRoute(8.720897, 50.002515, 8.723658, 49.997510, "testtrack");
// error message from router?
Assert.assertTrue("routing failed: " + msg, msg == null);
// 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());
// second test: to-point far off
msg = calcRoute(8.720897, 50.002515, 16.723658, 49.997510, "notrack");
Assert.assertTrue(msg, msg != null && msg.indexOf("not found") >= 0);
}
private String calcRoute(double flon, double flat, double tlon, double tlat, String trackname) throws Exception {
String wd = workingDir.getAbsolutePath();
List<OsmNodeNamed> wplist = new ArrayList<OsmNodeNamed>();
OsmNodeNamed n;
n = new OsmNodeNamed();
n.name = "from";
n.ilon = 180000000 + (int) (flon * 1000000 + 0.5);
n.ilat = 90000000 + (int) (flat * 1000000 + 0.5);
wplist.add(n);
n = new OsmNodeNamed();
n.name = "to";
n.ilon = 180000000 + (int) (tlon * 1000000 + 0.5);
n.ilat = 90000000 + (int) (tlat * 1000000 + 0.5);
wplist.add(n);
RoutingContext rctx = new RoutingContext();
rctx.localFunction = wd + "/../../../../misc/profiles2/trekking.brf";
// c.setAlternativeIdx( 1 );
RoutingEngine re = new RoutingEngine(
wd + "/" + trackname,
wd + "/" + trackname,
new File(wd, "/../../../../brouter-map-creator/build/resources/test/tmp/segments"),
wplist,
rctx);
re.doRun(0);
return re.getErrorMessage();
}
}

View file

@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- track-length = 736 filtered ascend = 0 plain-ascend = 0 cost=736 energy=.0kwh time=1m 53s -->
<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.720895" lat="50.002517"></trkpt>
<trkpt lon="8.720888" lat="50.002517"></trkpt>
<trkpt lon="8.720832" lat="50.002494"></trkpt>
<trkpt lon="8.720814" lat="50.002476"></trkpt>
<trkpt lon="8.720802" lat="50.002433"></trkpt>
<trkpt lon="8.720810" lat="50.002412"></trkpt>
<trkpt lon="8.720682" lat="50.002377"></trkpt>
<trkpt lon="8.720553" lat="50.002342"></trkpt>
<trkpt lon="8.720339" lat="50.002251"></trkpt>
<trkpt lon="8.720068" lat="50.002110"></trkpt>
<trkpt lon="8.719973" lat="50.002051"></trkpt>
<trkpt lon="8.719838" lat="50.001948"></trkpt>
<trkpt lon="8.719759" lat="50.001864"></trkpt>
<trkpt lon="8.719712" lat="50.001780"></trkpt>
<trkpt lon="8.719678" lat="50.001789"></trkpt>
<trkpt lon="8.719641" lat="50.001790"></trkpt>
<trkpt lon="8.719600" lat="50.001783"></trkpt>
<trkpt lon="8.719564" lat="50.001768"></trkpt>
<trkpt lon="8.719539" lat="50.001745"></trkpt>
<trkpt lon="8.719527" lat="50.001719"></trkpt>
<trkpt lon="8.719530" lat="50.001692"></trkpt>
<trkpt lon="8.719546" lat="50.001667"></trkpt>
<trkpt lon="8.719574" lat="50.001647"></trkpt>
<trkpt lon="8.719610" lat="50.001634"></trkpt>
<trkpt lon="8.719652" lat="50.001630"></trkpt>
<trkpt lon="8.719693" lat="50.001634"></trkpt>
<trkpt lon="8.719730" lat="50.001647"></trkpt>
<trkpt lon="8.719788" lat="50.001576"></trkpt>
<trkpt lon="8.719887" lat="50.001483"></trkpt>
<trkpt lon="8.719994" lat="50.001425"></trkpt>
<trkpt lon="8.720206" lat="50.001297"></trkpt>
<trkpt lon="8.720324" lat="50.001211"></trkpt>
<trkpt lon="8.720403" lat="50.001137"></trkpt>
<trkpt lon="8.720482" lat="50.001041"></trkpt>
<trkpt lon="8.720539" lat="50.000948"></trkpt>
<trkpt lon="8.720600" lat="50.000799"></trkpt>
<trkpt lon="8.720672" lat="50.000551"></trkpt>
<trkpt lon="8.720760" lat="50.000387"></trkpt>
<trkpt lon="8.720921" lat="50.000228"></trkpt>
<trkpt lon="8.721129" lat="50.000074"></trkpt>
<trkpt lon="8.721391" lat="49.999871"></trkpt>
<trkpt lon="8.721602" lat="49.999714"></trkpt>
<trkpt lon="8.722176" lat="49.999309"></trkpt>
<trkpt lon="8.722416" lat="49.999100"></trkpt>
<trkpt lon="8.722474" lat="49.999038"></trkpt>
<trkpt lon="8.722547" lat="49.998975"></trkpt>
<trkpt lon="8.722669" lat="49.998853"></trkpt>
<trkpt lon="8.723033" lat="49.998411"></trkpt>
<trkpt lon="8.723136" lat="49.998266"></trkpt>
<trkpt lon="8.723659" lat="49.997526"></trkpt>
<trkpt lon="8.723669" lat="49.997514"></trkpt>
</trkseg>
</trk>
</gpx>