Search in sources :

Example 21 with GHPoint

use of com.graphhopper.util.shapes.GHPoint in project graphhopper by graphhopper.

the class GraphHopperWebIT method testSimpleExport.

@Test
public void testSimpleExport() {
    GHRequest req = new GHRequest().addPoint(new GHPoint(49.6724, 11.3494)).addPoint(new GHPoint(49.6550, 11.4180));
    req.getHints().put("elevation", false);
    req.getHints().put("instructions", true);
    req.getHints().put("calc_points", true);
    req.getHints().put("type", "gpx");
    String res = gh.export(req);
    assertTrue(res.contains("<gpx"));
    assertTrue(res.contains("<rtept lat="));
    assertTrue(res.contains("<trk><name>GraphHopper Track</name><trkseg>"));
    assertTrue(res.endsWith("</gpx>"));
}
Also used : GHRequest(com.graphhopper.GHRequest) GHPoint(com.graphhopper.util.shapes.GHPoint) Test(org.junit.Test)

Example 22 with GHPoint

use of com.graphhopper.util.shapes.GHPoint in project graphhopper by graphhopper.

the class GraphHopperWebIT method readRoundabout.

@Test
public void readRoundabout() {
    GHRequest req = new GHRequest().addPoint(new GHPoint(52.261434, 13.485718)).addPoint(new GHPoint(52.399067, 13.469238));
    GHResponse res = gh.route(req);
    int counter = 0;
    for (Instruction i : res.getBest().getInstructions()) {
        if (i instanceof RoundaboutInstruction) {
            counter++;
            RoundaboutInstruction ri = (RoundaboutInstruction) i;
            assertEquals("turn_angle was incorrect:" + ri.getTurnAngle(), -1.5, ri.getTurnAngle(), 0.1);
            // This route contains only one roundabout and no (via) point in a roundabout
            assertEquals("exited was incorrect:" + ri.isExited(), ri.isExited(), true);
        }
    }
    assertTrue("no roundabout in route?", counter > 0);
}
Also used : GHRequest(com.graphhopper.GHRequest) RoundaboutInstruction(com.graphhopper.util.RoundaboutInstruction) Instruction(com.graphhopper.util.Instruction) RoundaboutInstruction(com.graphhopper.util.RoundaboutInstruction) GHPoint(com.graphhopper.util.shapes.GHPoint) GHResponse(com.graphhopper.GHResponse) GHPoint(com.graphhopper.util.shapes.GHPoint) Test(org.junit.Test)

Example 23 with GHPoint

use of com.graphhopper.util.shapes.GHPoint in project graphhopper by graphhopper.

the class GraphHopperWebIT method testPathDetails.

@Test
public void testPathDetails() {
    GHRequest req = new GHRequest().addPoint(new GHPoint(49.6724, 11.3494)).addPoint(new GHPoint(49.6550, 11.4180));
    req.getPathDetails().add("average_speed");
    GHResponse res = gh.route(req);
    assertFalse("errors:" + res.getErrors().toString(), res.hasErrors());
    PathWrapper alt = res.getBest();
    assertEquals(1, alt.getPathDetails().size());
    List<PathDetail> details = alt.getPathDetails().get("average_speed");
    assertFalse(details.isEmpty());
    assertTrue((Double) details.get(0).getValue() > 20);
    assertTrue((Double) details.get(0).getValue() < 70);
}
Also used : PathWrapper(com.graphhopper.PathWrapper) PathDetail(com.graphhopper.util.details.PathDetail) GHRequest(com.graphhopper.GHRequest) GHPoint(com.graphhopper.util.shapes.GHPoint) GHResponse(com.graphhopper.GHResponse) Test(org.junit.Test)

Example 24 with GHPoint

use of com.graphhopper.util.shapes.GHPoint in project graphhopper by graphhopper.

the class GraphHopperWebIT method testOutOfBoundsException.

@Test
public void testOutOfBoundsException() {
    GHRequest req = new GHRequest().addPoint(new GHPoint(-400.214943, -130.078125)).addPoint(new GHPoint(39.909736, -91.054687));
    GHResponse res = gh.route(req);
    assertTrue("no erros found?", res.hasErrors());
    assertTrue(res.getErrors().get(0) instanceof PointOutOfBoundsException);
}
Also used : GHRequest(com.graphhopper.GHRequest) PointOutOfBoundsException(com.graphhopper.util.exceptions.PointOutOfBoundsException) GHPoint(com.graphhopper.util.shapes.GHPoint) GHResponse(com.graphhopper.GHResponse) Test(org.junit.Test)

Example 25 with GHPoint

use of com.graphhopper.util.shapes.GHPoint in project graphhopper by graphhopper.

the class GraphHopperWebIT method testCreateGPXFromInstructionList.

@Test
public void testCreateGPXFromInstructionList() {
    GHRequest req = new GHRequest().addPoint(new GHPoint(49.6724, 11.3494)).addPoint(new GHPoint(49.6550, 11.4180));
    req.getHints().put("elevation", false);
    req.getHints().put("instructions", true);
    req.getHints().put("calc_points", true);
    GHResponse ghResponse = gh.route(req);
    String gpx = ghResponse.getBest().getInstructions().createGPX();
    assertTrue(gpx.contains("<gpx"));
    assertTrue(gpx.contains("<rtept lat="));
    assertTrue(gpx.contains("<trk><name>"));
    assertTrue(gpx.endsWith("</gpx>"));
}
Also used : GHRequest(com.graphhopper.GHRequest) GHPoint(com.graphhopper.util.shapes.GHPoint) GHResponse(com.graphhopper.GHResponse) Test(org.junit.Test)

Aggregations

GHPoint (com.graphhopper.util.shapes.GHPoint)206 Test (org.junit.jupiter.api.Test)62 GHRequest (com.graphhopper.GHRequest)57 GHResponse (com.graphhopper.GHResponse)50 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)50 Test (org.junit.Test)45 LMProfile (com.graphhopper.config.LMProfile)27 Profile (com.graphhopper.config.Profile)27 CustomProfile (com.graphhopper.routing.weighting.custom.CustomProfile)27 CHProfile (com.graphhopper.config.CHProfile)26 Snap (com.graphhopper.storage.index.Snap)17 QueryResult (com.graphhopper.storage.index.QueryResult)15 GraphHopperWeb (com.graphhopper.api.GraphHopperWeb)13 ResponsePath (com.graphhopper.ResponsePath)11 ArrayList (java.util.ArrayList)11 EnumSource (org.junit.jupiter.params.provider.EnumSource)11 PathWrapper (com.graphhopper.PathWrapper)8 PointNotFoundException (com.graphhopper.util.exceptions.PointNotFoundException)8 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)8 IntArrayList (com.carrotsearch.hppc.IntArrayList)6