use of com.graphhopper.config.LMProfile in project graphhopper by graphhopper.
the class MapMatching2Test method testIssue127.
@Test
public void testIssue127() throws IOException {
GraphHopper hopper = new GraphHopper();
hopper.setOSMFile("../map-matching/files/map-issue13.osm.gz");
hopper.setGraphHopperLocation(GH_LOCATION);
hopper.setProfiles(new Profile("my_profile").setVehicle("car").setWeighting("fastest"));
hopper.getLMPreparationHandler().setLMProfiles(new LMProfile("my_profile"));
hopper.importOrLoad();
MapMatching mapMatching = new MapMatching(hopper, new PMap().putObject("profile", "my_profile"));
// query with two identical points
Gpx gpx = xmlMapper.readValue(getClass().getResourceAsStream("/issue-127.gpx"), Gpx.class);
MatchResult mr = mapMatching.match(GpxConversions.getEntries(gpx.trk.get(0)));
// make sure no virtual edges are returned
int edgeCount = hopper.getGraphHopperStorage().getAllEdges().length();
for (EdgeMatch em : mr.getEdgeMatches()) {
assertTrue(em.getEdgeState().getEdge() < edgeCount, "result contains virtual edges:" + em.getEdgeState().toString());
validateEdgeMatch(em);
}
assertEquals(0, mr.getMatchMillis(), 50);
}
use of com.graphhopper.config.LMProfile in project graphhopper by graphhopper.
the class GraphHopperLandmarksTest method createConfig.
private static GraphHopperServerConfiguration createConfig() {
GraphHopperServerConfiguration config = new GraphHopperServerTestConfiguration();
config.getGraphHopperConfiguration().putObject("graph.flag_encoders", "car").putObject("datareader.file", "../core/files/belarus-east.osm.gz").putObject("prepare.min_network_size", 0).putObject("graph.location", DIR).putObject("prepare.lm.min_network_size", 2).setProfiles(Collections.singletonList(new Profile("car_profile").setVehicle("car").setWeighting("fastest"))).setCHProfiles(Collections.singletonList(new CHProfile("car_profile"))).setLMProfiles(Collections.singletonList(new LMProfile("car_profile")));
return config;
}
use of com.graphhopper.config.LMProfile in project graphhopper by graphhopper.
the class GraphHopperConfig method toString.
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("profiles:\n");
for (Profile profile : profiles) {
sb.append(profile);
sb.append("\n");
}
sb.append("profiles_ch:\n");
for (CHProfile profile : chProfiles) {
sb.append(profile);
sb.append("\n");
}
sb.append("profiles_lm:\n");
for (LMProfile profile : lmProfiles) {
sb.append(profile);
sb.append("\n");
}
sb.append("properties:\n");
for (Map.Entry<String, Object> entry : map.toMap().entrySet()) {
sb.append(entry.getKey()).append(": ").append(entry.getValue());
sb.append("\n");
}
return sb.toString();
}
use of com.graphhopper.config.LMProfile in project graphhopper by graphhopper.
the class GraphHopperTest method testImportCloseAndLoad.
private void testImportCloseAndLoad(boolean ch, boolean lm, boolean sort, boolean custom) {
final String vehicle = "foot";
final String profileName = "profile";
GraphHopper hopper = new GraphHopper().setGraphHopperLocation(GH_LOCATION).setOSMFile(MONACO).setStoreOnFlush(true).setSortGraph(sort);
Profile profile = new Profile(profileName).setVehicle(vehicle).setWeighting("fastest");
if (custom) {
JsonFeature area51Feature = new JsonFeature();
area51Feature.setGeometry(new GeometryFactory().createPolygon(new Coordinate[] { new Coordinate(7.4174, 43.7345), new Coordinate(7.4198, 43.7355), new Coordinate(7.4207, 43.7344), new Coordinate(7.4174, 43.7345) }));
CustomModel customModel = new CustomModel().setDistanceInfluence(0);
customModel.getPriority().add(Statement.If("in_area51", Statement.Op.MULTIPLY, 0.1));
customModel.getAreas().put("area51", area51Feature);
profile = new CustomProfile(profileName).setCustomModel(customModel).setVehicle(vehicle);
}
hopper.setProfiles(profile);
if (ch) {
hopper.getCHPreparationHandler().setCHProfiles(new CHProfile(profileName));
}
if (lm) {
hopper.getLMPreparationHandler().setLMProfiles(new LMProfile(profileName));
}
hopper.importAndClose();
hopper = new GraphHopper().setGraphHopperLocation(GH_LOCATION).setOSMFile(MONACO).setProfiles(profile).setStoreOnFlush(true).setAllowWrites(false);
if (ch) {
hopper.getCHPreparationHandler().setCHProfiles(new CHProfile(profileName));
}
if (lm) {
hopper.getLMPreparationHandler().setLMProfiles(new LMProfile(profileName));
}
hopper.importOrLoad();
if (ch) {
GHRequest req = new GHRequest(43.727687, 7.418737, 43.74958, 7.436566).setProfile(profileName);
req.putHint(CH.DISABLE, false);
req.putHint(Landmark.DISABLE, true);
GHResponse rsp = hopper.route(req);
ResponsePath bestPath = rsp.getBest();
long sum = rsp.getHints().getLong("visited_nodes.sum", 0);
assertNotEquals(sum, 0);
assertTrue(sum < 155, "Too many nodes visited " + sum);
assertEquals(3535, bestPath.getDistance(), 1);
assertEquals(115, bestPath.getPoints().size());
}
if (lm) {
GHRequest req = new GHRequest(43.727687, 7.418737, 43.74958, 7.436566).setProfile(profileName).setAlgorithm(Parameters.Algorithms.ASTAR_BI);
req.putHint(CH.DISABLE, true);
req.putHint(Landmark.DISABLE, false);
GHResponse rsp = hopper.route(req);
ResponsePath bestPath = rsp.getBest();
long sum = rsp.getHints().getLong("visited_nodes.sum", 0);
assertNotEquals(sum, 0);
assertTrue(sum < 125, "Too many nodes visited " + sum);
assertEquals(3535, bestPath.getDistance(), 1);
assertEquals(115, bestPath.getPoints().size());
}
// flexible
GHRequest req = new GHRequest(43.727687, 7.418737, 43.74958, 7.436566).setProfile(profileName);
req.putHint(CH.DISABLE, true);
req.putHint(Landmark.DISABLE, true);
GHResponse rsp = hopper.route(req);
ResponsePath bestPath = rsp.getBest();
long sum = rsp.getHints().getLong("visited_nodes.sum", 0);
assertNotEquals(sum, 0);
assertTrue(sum > 120, "Too few nodes visited " + sum);
assertEquals(3535, bestPath.getDistance(), 1);
assertEquals(115, bestPath.getPoints().size());
hopper.close();
}
use of com.graphhopper.config.LMProfile in project graphhopper by graphhopper.
the class GraphHopperTest method testIssue1960.
@Test
public void testIssue1960() {
final String profile = "car";
final String vehicle = "car";
final String weighting = "fastest";
GraphHopper hopper = new GraphHopper().setGraphHopperLocation(GH_LOCATION).setOSMFile(MOSCOW).setProfiles(new Profile(profile).setVehicle(vehicle).setWeighting(weighting).setTurnCosts(true));
hopper.getCHPreparationHandler().setCHProfiles(new CHProfile(profile));
hopper.getLMPreparationHandler().setLMProfiles(new LMProfile(profile));
hopper.importOrLoad();
GHRequest req = new GHRequest(55.815670, 37.604613, 55.806151, 37.617823);
req.setProfile("car");
req.getHints().putObject(CH.DISABLE, false).putObject(Landmark.DISABLE, true);
ResponsePath pathCH = hopper.route(req).getBest();
req.getHints().putObject(CH.DISABLE, true).putObject(Landmark.DISABLE, false);
ResponsePath pathLM = hopper.route(req).getBest();
req.getHints().putObject(CH.DISABLE, true).putObject(Landmark.DISABLE, true);
ResponsePath path = hopper.route(req).getBest();
assertEquals(1995.38, pathCH.getDistance(), 0.1);
assertEquals(1995.38, pathLM.getDistance(), 0.1);
assertEquals(1995.38, path.getDistance(), 0.1);
assertEquals(149497, pathCH.getTime());
assertEquals(149497, pathLM.getTime());
assertEquals(149497, path.getTime());
}
Aggregations