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

show problem with motorway_link #148

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ nbactions.xml
.classpath
.project
matching-core/build.xml
/map-data/**/*
bin/
/matching-core/nbproject/
matching-web/dependency-reduced-pom.xml
Binary file added map-data/map-issue147.osm.gz
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void testIssue127() throws IOException {
assertEquals(0, mr.getMatchMillis(), 50);
}

private void validateEdgeMatch(EdgeMatch edgeMatch) {
static void validateEdgeMatch(EdgeMatch edgeMatch) {
for (GPXExtension gpxExtension : edgeMatch.getGpxExtensions()) {
if (gpxExtension.getQueryResult().getSnappedPosition() == QueryResult.Position.TOWER) {
if (gpxExtension.getQueryResult().getClosestNode() != edgeMatch.getEdgeState().getAdjNode()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Licensed to GraphHopper GmbH under one or more contributor
* license agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* GraphHopper GmbH licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.graphhopper.matching;

import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.graphhopper.GraphHopper;
import com.graphhopper.matching.gpx.Gpx;
import com.graphhopper.reader.osm.GraphHopperOSM;
import com.graphhopper.routing.AlgorithmOptions;
import com.graphhopper.routing.util.CarFlagEncoder;
import com.graphhopper.routing.util.EncodingManager;
import com.graphhopper.util.Helper;
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;

import static com.graphhopper.matching.MapMatchingTest.fetchStreets;
import static org.junit.Assert.assertEquals;

/**
* @author Peter Karich
*/
public class MapMatching3Test {

private static final String DIR = "../target/mapmatchingtest-147";

@BeforeClass
public static void setUp() {
Helper.removeDir(new File(DIR));
}

@Test
public void testIssue147() throws IOException {
CarFlagEncoder encoder = new CarFlagEncoder() {
{
// TODO NOW this test is only green for a very low value like 2
defaultSpeedMap.put("motorway_link", 50);
}
};
GraphHopper hopper = new GraphHopperOSM();
hopper.setDataReaderFile("../map-data/map-issue147.osm.gz");
hopper.setGraphHopperLocation(DIR);
EncodingManager em = new EncodingManager.Builder(4).add(encoder).build();
hopper.setEncodingManager(em);
hopper.getCHFactoryDecorator().setDisablingAllowed(true);
hopper.importOrLoad();

AlgorithmOptions opts = AlgorithmOptions.start().build();
MapMatching mapMatching = new MapMatching(hopper, opts);

Gpx gpx = new XmlMapper().readValue(getClass().getResourceAsStream("/issue-147.gpx"), Gpx.class);
MatchResult mr = mapMatching.doWork(gpx.trk.get(0).getEntries());

// always match motorway
assertEquals(Arrays.asList("I 90", "I 90", "I 90", "I 90", "I 90"), fetchStreets(mr.getEdgeMatches()));
assertEquals(3047, mr.getMatchLength(), 1);
}
}
28 changes: 28 additions & 0 deletions matching-web/src/test/resources/issue-147.gpx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpsies="http://www.gpsies.com/GPX/1/0" creator="GPSies http://www.gpsies.com - Sendl.-O&amp;apos;sch-heim" version="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 http://www.gpsies.com/GPX/1/0 http://www.gpsies.com/gpsies.xsd">
<metadata>
<name>JYB928 2019-01-02 0547</name>
<link href="http://www.gpsies.com/map.do?fileId=opyocvowlvfftwsr">
<text>JYB928 2019-01-02 0547</text>
<type>trackOnWeb</type>
</link>
<time>2016-07-14T17:55:52Z</time>
</metadata>
<trk>
<trkseg>
<trkpt lat="47.579491" lon="-122.15713">
<time>2019-01-02T08:25:47Z</time>
</trkpt>
<trkpt lat="47.578704" lon="-122.14">
<time>2019-01-02T08:26:47Z</time>
</trkpt>
<trkpt lat="47.578472" lon="-122.136157">
<time>2019-01-02T08:27:07Z</time>
</trkpt>
<trkpt lat="47.573102" lon="-122.118426">
<time>2019-01-02T08:27:47Z</time>
</trkpt>
</trkseg>
</trk>
</gpx>