Search in sources :

Example 16 with ReaderWay

use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.

the class GraphHopperTest method testSRTMWithTunnelInterpolation.

@ParameterizedTest
@ValueSource(booleans = { true, false })
public void testSRTMWithTunnelInterpolation(boolean withTunnelInterpolation) {
    final String profile = "profile";
    final String vehicle = "foot";
    final String weighting = "shortest";
    GraphHopper hopper = new GraphHopper().setGraphHopperLocation(GH_LOCATION).setOSMFile(MONACO).setProfiles(new Profile(profile).setVehicle(vehicle).setWeighting(weighting)).setStoreOnFlush(true);
    if (!withTunnelInterpolation) {
        hopper.getEncodingManagerBuilder().add(new OSMRoadEnvironmentParser() {

            @Override
            public IntsRef handleWayTags(IntsRef edgeFlags, ReaderWay readerWay, IntsRef relationFlags) {
                // do not change RoadEnvironment to avoid triggering tunnel interpolation
                return edgeFlags;
            }
        }).addIfAbsent(new DefaultFlagEncoderFactory(), vehicle);
    }
    hopper.setElevationProvider(new SRTMProvider(DIR));
    hopper.importOrLoad();
    GHPoint from = new GHPoint(43.7405647, 7.4299266);
    GHPoint to = new GHPoint(43.7378990, 7.4279780);
    // make sure we hit tower nodes, because all we really want is test the elevation interpolation
    assertEquals(Snap.Position.TOWER, hopper.getLocationIndex().findClosest(from.lat, from.lon, EdgeFilter.ALL_EDGES).getSnappedPosition());
    assertEquals(Snap.Position.TOWER, hopper.getLocationIndex().findClosest(to.lat, to.lon, EdgeFilter.ALL_EDGES).getSnappedPosition());
    GHResponse rsp = hopper.route(new GHRequest(from, to).setProfile(profile));
    ResponsePath res = rsp.getBest();
    PointList pointList = res.getPoints();
    assertEquals(6, pointList.size());
    assertTrue(pointList.is3D());
    if (withTunnelInterpolation) {
        assertEquals(351.8, res.getDistance(), .1);
        assertEquals(17, pointList.getEle(0), .1);
        assertEquals(19.04, pointList.getEle(1), .1);
        assertEquals(21.67, pointList.getEle(2), .1);
        assertEquals(25.03, pointList.getEle(3), .1);
        assertEquals(28.65, pointList.getEle(4), .1);
        assertEquals(34.00, pointList.getEle(5), .1);
    } else {
        assertEquals(358.3, res.getDistance(), .1);
        assertEquals(17.0, pointList.getEle(0), .1);
        assertEquals(23.0, pointList.getEle(1), .1);
        assertEquals(23.0, pointList.getEle(2), .1);
        assertEquals(41.0, pointList.getEle(3), .1);
        assertEquals(19.0, pointList.getEle(4), .1);
        assertEquals(34.0, pointList.getEle(5), .1);
    }
}
Also used : ReaderWay(com.graphhopper.reader.ReaderWay) CustomProfile(com.graphhopper.routing.weighting.custom.CustomProfile) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) SRTMProvider(com.graphhopper.reader.dem.SRTMProvider) OSMRoadEnvironmentParser(com.graphhopper.routing.util.parsers.OSMRoadEnvironmentParser) IntsRef(com.graphhopper.storage.IntsRef) GHPoint(com.graphhopper.util.shapes.GHPoint) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with ReaderWay

use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.

the class ConditionalOSMTagInspectorTest method testConditionalAllowance.

@Test
public void testConditionalAllowance() {
    Calendar cal = getCalendar(2014, Calendar.MARCH, 10);
    ConditionalTagInspector acceptor = new ConditionalOSMTagInspector(cal, getSampleConditionalTags(), getSampleRestrictedValues(), getSamplePermissiveValues());
    ReaderWay way = new ReaderWay(1);
    way.setTag("vehicle:conditional", "yes @ (Mar 10-Aug 14)");
    assertTrue(acceptor.isRestrictedWayConditionallyPermitted(way));
}
Also used : ConditionalTagInspector(com.graphhopper.reader.ConditionalTagInspector) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 18 with ReaderWay

use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.

the class ConditionalOSMTagInspectorTest method testConditionalAccept.

@Test
public void testConditionalAccept() {
    Calendar cal = getCalendar(2014, Calendar.MARCH, 10);
    ConditionalTagInspector acceptor = new ConditionalOSMTagInspector(cal, getSampleConditionalTags(), getSampleRestrictedValues(), getSamplePermissiveValues());
    ReaderWay way = new ReaderWay(1);
    way.setTag("vehicle:conditional", "no @ (Aug 10-Aug 14)");
    assertFalse(acceptor.isPermittedWayConditionallyRestricted(way));
}
Also used : ConditionalTagInspector(com.graphhopper.reader.ConditionalTagInspector) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 19 with ReaderWay

use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.

the class ConditionalOSMTagInspectorTest method testConditionalAllowanceReject.

@Test
public void testConditionalAllowanceReject() {
    Calendar cal = getCalendar(2014, Calendar.MARCH, 10);
    ConditionalTagInspector acceptor = new ConditionalOSMTagInspector(cal, getSampleConditionalTags(), getSampleRestrictedValues(), getSamplePermissiveValues());
    ReaderWay way = new ReaderWay(1);
    way.setTag("vehicle:conditional", "no @ (Mar 10-Aug 14)");
    assertTrue(acceptor.isPermittedWayConditionallyRestricted(way));
}
Also used : ConditionalTagInspector(com.graphhopper.reader.ConditionalTagInspector) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Example 20 with ReaderWay

use of com.graphhopper.reader.ReaderWay in project graphhopper by graphhopper.

the class ConditionalOSMTagInspectorTest method testConditionalAcceptNextYear.

@Test
public void testConditionalAcceptNextYear() {
    Calendar cal = getCalendar(2014, Calendar.MARCH, 10);
    ConditionalTagInspector acceptor = new ConditionalOSMTagInspector(cal, getSampleConditionalTags(), getSampleRestrictedValues(), getSamplePermissiveValues());
    ReaderWay way = new ReaderWay(1);
    way.setTag("vehicle:conditional", "no @ (2013 Mar 1-2013 Mar 31)");
    assertFalse(acceptor.isPermittedWayConditionallyRestricted(way));
}
Also used : ConditionalTagInspector(com.graphhopper.reader.ConditionalTagInspector) ReaderWay(com.graphhopper.reader.ReaderWay) Test(org.junit.jupiter.api.Test)

Aggregations

ReaderWay (com.graphhopper.reader.ReaderWay)157 Test (org.junit.jupiter.api.Test)119 IntsRef (com.graphhopper.storage.IntsRef)67 Test (org.junit.Test)24 EncodingManager (com.graphhopper.routing.util.EncodingManager)9 GraphBuilder (com.graphhopper.storage.GraphBuilder)9 ReaderRelation (com.graphhopper.reader.ReaderRelation)8 ConditionalTagInspector (com.graphhopper.reader.ConditionalTagInspector)7 Graph (com.graphhopper.storage.Graph)7 DateFormat (java.text.DateFormat)6 Date (java.util.Date)6 DecimalEncodedValue (com.graphhopper.routing.ev.DecimalEncodedValue)5 EdgeIteratorState (com.graphhopper.util.EdgeIteratorState)5 CarFlagEncoder (com.graphhopper.routing.util.CarFlagEncoder)4 PMap (com.graphhopper.util.PMap)4 BooleanEncodedValue (com.graphhopper.routing.ev.BooleanEncodedValue)3 DataFlagEncoder (com.graphhopper.routing.util.DataFlagEncoder)3 FlagEncoder (com.graphhopper.routing.util.FlagEncoder)3 GHPoint (com.graphhopper.util.shapes.GHPoint)3 LongIndexedContainer (com.carrotsearch.hppc.LongIndexedContainer)2