Skip to content
This repository has been archived by the owner on Mar 1, 2021. It is now read-only.

Commit

Permalink
Fix all failed unit tests except testUTurns for CH
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanholder committed Dec 12, 2016
1 parent bfd268e commit e4ad3a2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public MatchResult doWork(List<GPXEntry> gpxList) {
+ " filtered GPX entries (from " + gpxList.size()
+ "), but two or more are needed");
}

// now find each of the entries in the graph:
final EdgeFilter edgeFilter = new DefaultEdgeFilter(algoOptions.getWeighting().getFlagEncoder());

Expand Down Expand Up @@ -254,7 +254,9 @@ private List<GPXEntry> filterGPXEntries(List<GPXEntry> gpxList) {
gpxEntry.getLat(), gpxEntry.getLon()) > 2 * measurementErrorSigma) {
filtered.add(gpxEntry);
prevEntry = gpxEntry;
}
} else {
logger.info("Filter out GPX entry: {}", i + 1);
}
}
return filtered;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public MapMatchingTest(String name, TestGraphHopper hopper, AlgorithmOptions alg

@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> algoOptions() {

// create hopper instance with CH enabled
CarFlagEncoder encoder = new CarFlagEncoder();
TestGraphHopper hopper = new TestGraphHopper();
Expand All @@ -80,17 +79,23 @@ public static Collection<Object[]> algoOptions() {
hopper.setEncodingManager(new EncodingManager(encoder));
hopper.importOrLoad();

// Reduce penalty to allow U-turns in testUTurns
final double HEADING_PENALTY = 50;

// force CH
AlgorithmOptions chOpts = AlgorithmOptions.start()
.maxVisitedNodes(1000)
.hints(new PMap().put(Parameters.CH.DISABLE, false))
.hints(new PMap().put(Parameters.CH.DISABLE, false)
//TODO Fix that CH routing still uses default penalty of 300
.put(Parameters.Routing.HEADING_PENALTY, HEADING_PENALTY))
.build();

// flexible should fall back to defaults
AlgorithmOptions flexibleOpts = AlgorithmOptions.start().
AlgorithmOptions flexibleOpts = AlgorithmOptions.start()
// TODO: fewer nodes than for CH are possible (short routes & different finish condition & higher degree graph)
// maxVisitedNodes(20).
build();
// .maxVisitedNodes(20)
.hints(new PMap().put(Parameters.Routing.HEADING_PENALTY, HEADING_PENALTY))
.build();

return Arrays.asList(new Object[][]{
{"non-CH", hopper, flexibleOpts},
Expand Down Expand Up @@ -179,8 +184,9 @@ public void testDistantPoints() {
new GHPoint(51.23, 12.18),
new GHPoint(51.45, 12.59));
MatchResult mr = mapMatching.doWork(inputGPXEntries);
assertEquals(mr.getMatchLength(), 57653, 1);
assertEquals(mr.getMatchMillis(), 2748186, 1);

assertEquals(57650, mr.getMatchLength(), 1);
assertEquals(2747796, mr.getMatchMillis(), 1);

// not OK when we only allow a small number of visited nodes:
AlgorithmOptions opts = AlgorithmOptions.start(algoOptions).maxVisitedNodes(1).build();
Expand Down Expand Up @@ -219,6 +225,10 @@ public void testSmallSeparatedSearchDistance() {
@Test
public void testLoop() {
MapMatching mapMatching = new MapMatching(hopper, algoOptions);

// Need to reduce GPS accuracy because too many GPX are filtered out otherwise.
mapMatching.setMeasurementErrorSigma(40);

List<GPXEntry> inputGPXEntries = new GPXFile()
.doImport("./src/test/resources/tour2-with-loop.gpx").getEntries();
MatchResult mr = mapMatching.doWork(inputGPXEntries);
Expand Down Expand Up @@ -265,12 +275,14 @@ public void testUTurns() {
// with large measurement error, we expect no U-turn
mapMatching.setMeasurementErrorSigma(50);
MatchResult mr = mapMatching.doWork(inputGPXEntries);

assertEquals(Arrays.asList("Gustav-Adolf-Straße", "Gustav-Adolf-Straße", "Funkenburgstraße",
"Funkenburgstraße"), fetchStreets(mr.getEdgeMatches()));

// with small measurement error, we expect the U-turn
mapMatching.setMeasurementErrorSigma(10);
mr = mapMatching.doWork(inputGPXEntries);

assertEquals(
Arrays.asList("Gustav-Adolf-Straße", "Gustav-Adolf-Straße", "Funkenburgstraße",
"Funkenburgstraße", "Funkenburgstraße", "Funkenburgstraße"),
Expand Down

0 comments on commit e4ad3a2

Please sign in to comment.