Merge pull request #557 from zod/elevation-tests

Use elevation data in tests
This commit is contained in:
afischerdev 2023-05-22 14:13:28 +02:00 committed by GitHub
commit fb5f293dc9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 71 additions and 77 deletions

View file

@ -1,76 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- track-length = 1902 filtered ascend = 0 plain-ascend = 0 cost=2753 energy=.0kwh time=5m 9s --> <!-- track-length = 1570 filtered ascend = 4 plain-ascend = -15 cost=2840 energy=.0kwh time=3m 45s -->
<gpx <gpx
xmlns="http://www.topografix.com/GPX/1/1" xmlns="http://www.topografix.com/GPX/1/1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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" 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"> creator="BRouter-1.7.0" version="1.1">
<trk> <trk>
<name>brouter_trekking_0</name> <name>brouter_trekking_0</name>
<trkseg> <trkseg>
<trkpt lon="8.723027" lat="50.000499"></trkpt> <trkpt lon="8.723027" lat="50.000499"><ele>175.25</ele></trkpt>
<trkpt lon="8.723285" lat="50.000610"></trkpt> <trkpt lon="8.723285" lat="50.000610"><ele>176.75</ele></trkpt>
<trkpt lon="8.724003" lat="50.000939"></trkpt> <trkpt lon="8.724003" lat="50.000939"><ele>179.25</ele></trkpt>
<trkpt lon="8.724437" lat="50.000856"></trkpt> <trkpt lon="8.723553" lat="50.001028"><ele>177.5</ele></trkpt>
<trkpt lon="8.724590" lat="50.000810"></trkpt> <trkpt lon="8.723041" lat="50.001194"><ele>174.5</ele></trkpt>
<trkpt lon="8.724778" lat="50.000741"></trkpt> <trkpt lon="8.722781" lat="50.001312"><ele>173.25</ele></trkpt>
<trkpt lon="8.725133" lat="50.001318"></trkpt> <trkpt lon="8.722027" lat="50.001834"><ele>169.5</ele></trkpt>
<trkpt lon="8.725379" lat="50.001518"></trkpt> <trkpt lon="8.721982" lat="50.001865"><ele>169.5</ele></trkpt>
<trkpt lon="8.725365" lat="50.001683"></trkpt> <trkpt lon="8.722320" lat="50.002050"><ele>171.0</ele></trkpt>
<trkpt lon="8.725388" lat="50.001830"></trkpt> <trkpt lon="8.722449" lat="50.002197"><ele>171.25</ele></trkpt>
<trkpt lon="8.725421" lat="50.001903"></trkpt> <trkpt lon="8.722497" lat="50.002337"><ele>171.25</ele></trkpt>
<trkpt lon="8.725492" lat="50.002032"></trkpt> <trkpt lon="8.722506" lat="50.002463"><ele>171.0</ele></trkpt>
<trkpt lon="8.725642" lat="50.002152"></trkpt> <trkpt lon="8.722486" lat="50.002697"><ele>170.25</ele></trkpt>
<trkpt lon="8.725847" lat="50.002262"></trkpt> <trkpt lon="8.721892" lat="50.002631"><ele>167.75</ele></trkpt>
<trkpt lon="8.725994" lat="50.002570"></trkpt> <trkpt lon="8.721836" lat="50.002624"><ele>167.5</ele></trkpt>
<trkpt lon="8.726143" lat="50.002754"></trkpt> <trkpt lon="8.721209" lat="50.002553"><ele>165.25</ele></trkpt>
<trkpt lon="8.726166" lat="50.002864"></trkpt> <trkpt lon="8.721118" lat="50.002538"><ele>164.75</ele></trkpt>
<trkpt lon="8.725143" lat="50.002880"></trkpt> <trkpt lon="8.721021" lat="50.002493"><ele>164.5</ele></trkpt>
<trkpt lon="8.724635" lat="50.002851"></trkpt> <trkpt lon="8.720994" lat="50.002509"><ele>164.25</ele></trkpt>
<trkpt lon="8.723968" lat="50.002840"></trkpt> <trkpt lon="8.720960" lat="50.002518"><ele>164.25</ele></trkpt>
<trkpt lon="8.723534" lat="50.002821"></trkpt> <trkpt lon="8.720888" lat="50.002517"><ele>163.75</ele></trkpt>
<trkpt lon="8.722486" lat="50.002697"></trkpt> <trkpt lon="8.720853" lat="50.002586"><ele>163.75</ele></trkpt>
<trkpt lon="8.721892" lat="50.002631"></trkpt> <trkpt lon="8.720782" lat="50.002704"><ele>163.25</ele></trkpt>
<trkpt lon="8.721836" lat="50.002624"></trkpt> <trkpt lon="8.720554" lat="50.002937"><ele>162.25</ele></trkpt>
<trkpt lon="8.721209" lat="50.002553"></trkpt> <trkpt lon="8.720469" lat="50.003004"><ele>162.0</ele></trkpt>
<trkpt lon="8.721118" lat="50.002538"></trkpt> <trkpt lon="8.718899" lat="50.003724"><ele>160.0</ele></trkpt>
<trkpt lon="8.721021" lat="50.002493"></trkpt> <trkpt lon="8.718254" lat="50.004051"><ele>159.25</ele></trkpt>
<trkpt lon="8.720994" lat="50.002509"></trkpt> <trkpt lon="8.718123" lat="50.004087"><ele>159.0</ele></trkpt>
<trkpt lon="8.720960" lat="50.002518"></trkpt> <trkpt lon="8.717543" lat="50.004244"><ele>159.0</ele></trkpt>
<trkpt lon="8.720888" lat="50.002517"></trkpt> <trkpt lon="8.717181" lat="50.004357"><ele>159.0</ele></trkpt>
<trkpt lon="8.720853" lat="50.002586"></trkpt> <trkpt lon="8.716729" lat="50.004515"><ele>158.0</ele></trkpt>
<trkpt lon="8.720782" lat="50.002704"></trkpt> <trkpt lon="8.716463" lat="50.004600"><ele>157.5</ele></trkpt>
<trkpt lon="8.720554" lat="50.002937"></trkpt> <trkpt lon="8.715713" lat="50.004799"><ele>156.25</ele></trkpt>
<trkpt lon="8.720469" lat="50.003004"></trkpt> <trkpt lon="8.715490" lat="50.004843"><ele>156.0</ele></trkpt>
<trkpt lon="8.718899" lat="50.003724"></trkpt> <trkpt lon="8.714977" lat="50.004918"><ele>155.25</ele></trkpt>
<trkpt lon="8.718254" lat="50.004051"></trkpt> <trkpt lon="8.714539" lat="50.005012"><ele>154.25</ele></trkpt>
<trkpt lon="8.718123" lat="50.004087"></trkpt> <trkpt lon="8.713784" lat="50.005136"><ele>152.5</ele></trkpt>
<trkpt lon="8.717543" lat="50.004244"></trkpt> <trkpt lon="8.713582" lat="50.005177"><ele>152.5</ele></trkpt>
<trkpt lon="8.717181" lat="50.004357"></trkpt> <trkpt lon="8.713316" lat="50.005086"><ele>153.0</ele></trkpt>
<trkpt lon="8.716729" lat="50.004515"></trkpt> <trkpt lon="8.713067" lat="50.005001"><ele>153.25</ele></trkpt>
<trkpt lon="8.716463" lat="50.004600"></trkpt> <trkpt lon="8.712848" lat="50.004896"><ele>153.75</ele></trkpt>
<trkpt lon="8.715713" lat="50.004799"></trkpt> <trkpt lon="8.712781" lat="50.004859"><ele>154.0</ele></trkpt>
<trkpt lon="8.715490" lat="50.004843"></trkpt> <trkpt lon="8.712667" lat="50.004765"><ele>154.25</ele></trkpt>
<trkpt lon="8.714977" lat="50.004918"></trkpt> <trkpt lon="8.712563" lat="50.004683"><ele>154.5</ele></trkpt>
<trkpt lon="8.714539" lat="50.005012"></trkpt> <trkpt lon="8.712154" lat="50.004321"><ele>156.25</ele></trkpt>
<trkpt lon="8.713784" lat="50.005136"></trkpt> <trkpt lon="8.712066" lat="50.004245"><ele>156.5</ele></trkpt>
<trkpt lon="8.713582" lat="50.005177"></trkpt> <trkpt lon="8.713422" lat="50.003599"><ele>158.5</ele></trkpt>
<trkpt lon="8.713316" lat="50.005086"></trkpt> <trkpt lon="8.713452" lat="50.003572"><ele>158.5</ele></trkpt>
<trkpt lon="8.713067" lat="50.005001"></trkpt> <trkpt lon="8.713592" lat="50.003347"><ele>158.5</ele></trkpt>
<trkpt lon="8.712848" lat="50.004896"></trkpt> <trkpt lon="8.713620" lat="50.003326"><ele>158.5</ele></trkpt>
<trkpt lon="8.712781" lat="50.004859"></trkpt> <trkpt lon="8.713956" lat="50.003142"><ele>158.5</ele></trkpt>
<trkpt lon="8.712667" lat="50.004765"></trkpt> <trkpt lon="8.713468" lat="50.002781"><ele>159.5</ele></trkpt>
<trkpt lon="8.712563" lat="50.004683"></trkpt> <trkpt lon="8.713293" lat="50.002684"><ele>159.75</ele></trkpt>
<trkpt lon="8.712154" lat="50.004321"></trkpt> <trkpt lon="8.712770" lat="50.002929"><ele>159.5</ele></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> </trkseg>
</trk> </trk>
</gpx> </gpx>

View file

@ -165,7 +165,7 @@ public class ConvertLidarTile {
String s = "E"; String s = "E";
if (lon < 0) { if (lon < 0) {
lon = -lon; lon = -lon;
s = "E"; s = "W";
} }
String n = "000" + lon; String n = "000" + lon;
return s + n.substring(n.length() - 3); return s + n.substring(n.length() - 3);

View file

@ -214,22 +214,23 @@ public class PosUnifier extends MapCreatorBase {
double lat = (ilat - 90000000) / 1000000.; double lat = (ilat - 90000000) / 1000000.;
String filename = buildHgtFilename(lat, lon); String filename = buildHgtFilename(lat, lon);
lastSrtmRaster = srtmmap.get(filename); // don't block lastSrtmRaster
if (lastSrtmRaster == null) { SrtmRaster srtm = srtmmap.get(filename);
if (srtm == null) {
File f = new File(new File(srtmdir), filename + ".hgt"); File f = new File(new File(srtmdir), filename + ".hgt");
if (f.exists()) { if (f.exists()) {
lastSrtmRaster = new ConvertLidarTile().getRaster(f, lon, lat); srtm = new ConvertLidarTile().getRaster(f, lon, lat);
srtmmap.put(filename, lastSrtmRaster); srtmmap.put(filename, srtm);
return lastSrtmRaster; return srtm;
} }
f = new File(new File(srtmdir), filename + ".zip"); f = new File(new File(srtmdir), filename + ".zip");
if (f.exists()) { if (f.exists()) {
lastSrtmRaster = new ConvertLidarTile().getRaster(f, lon, lat); srtm = new ConvertLidarTile().getRaster(f, lon, lat);
srtmmap.put(filename, lastSrtmRaster); srtmmap.put(filename, srtm);
return lastSrtmRaster; return srtm;
} }
} }
return lastSrtmRaster; return srtm;
} }
private String buildHgtFilename(double llat, double llon) { private String buildHgtFilename(double llat, double llon) {

View file

@ -42,7 +42,7 @@ public class MapcreatorTest {
File unodes55 = new File(tmpdir, "unodes55"); File unodes55 = new File(tmpdir, "unodes55");
File bordernodes = new File(tmpdir, "bordernodes.dat"); File bordernodes = new File(tmpdir, "bordernodes.dat");
unodes55.mkdir(); unodes55.mkdir();
new PosUnifier().process(nodes55, unodes55, borderFile, bordernodes, "/private-backup/srtm"); new PosUnifier().process(nodes55, unodes55, borderFile, bordernodes, workingDir.getAbsolutePath());
// run WayLinker // run WayLinker
File segments = new File(tmpdir, "segments"); File segments = new File(tmpdir, "segments");

Binary file not shown.

Binary file not shown.

View file

@ -77,6 +77,8 @@ public class RouteServerTest {
InputStream inputStream = httpConnection.getInputStream(); InputStream inputStream = httpConnection.getInputStream();
JSONObject geoJson = new JSONObject(new String(inputStream.readAllBytes(), StandardCharsets.UTF_8)); JSONObject geoJson = new JSONObject(new String(inputStream.readAllBytes(), StandardCharsets.UTF_8));
Assert.assertEquals("1169", geoJson.query("/features/0/properties/track-length")); Assert.assertEquals("1169", geoJson.query("/features/0/properties/track-length"));
Assert.assertEquals("-15", geoJson.query("/features/0/properties/plain-ascend"));
Assert.assertEquals("4", geoJson.query("/features/0/properties/filtered ascend"));
} }
@Test @Test
@ -89,7 +91,7 @@ public class RouteServerTest {
InputStream inputStream = httpConnection.getInputStream(); InputStream inputStream = httpConnection.getInputStream();
JSONObject geoJson = new JSONObject(new String(inputStream.readAllBytes(), StandardCharsets.UTF_8)); JSONObject geoJson = new JSONObject(new String(inputStream.readAllBytes(), StandardCharsets.UTF_8));
Assert.assertEquals("1866", geoJson.query("/features/0/properties/track-length")); Assert.assertEquals("1570", geoJson.query("/features/0/properties/track-length"));
} }
@Test @Test