use of com.graphhopper.util.CustomModel in project graphhopper by graphhopper.
the class CustomModelParserTest method multipleAreas.
@Test
public void multipleAreas() {
CustomModel customModel = new CustomModel();
Map<String, JsonFeature> areas = new HashMap<>();
Coordinate[] area_1_coordinates = new Coordinate[] { new Coordinate(48.019324184801185, 11.28021240234375), new Coordinate(48.019324184801185, 11.53564453125), new Coordinate(48.11843396091691, 11.53564453125), new Coordinate(48.11843396091691, 11.28021240234375), new Coordinate(48.019324184801185, 11.28021240234375) };
Coordinate[] area_2_coordinates = new Coordinate[] { new Coordinate(48.15509285476017, 11.53289794921875), new Coordinate(48.15509285476017, 11.8212890625), new Coordinate(48.281365151571755, 11.8212890625), new Coordinate(48.281365151571755, 11.53289794921875), new Coordinate(48.15509285476017, 11.53289794921875) };
areas.put("area_1", new JsonFeature("area_1", "Feature", null, new GeometryFactory().createPolygon(area_1_coordinates), new HashMap<>()));
areas.put("area_2", new JsonFeature("area_2", "Feature", null, new GeometryFactory().createPolygon(area_2_coordinates), new HashMap<>()));
customModel.setAreas(areas);
customModel.addToSpeed(If("in_area_1", LIMIT, 100));
customModel.addToSpeed(If("!in_area_2", LIMIT, 25));
customModel.addToSpeed(Else(LIMIT, 15));
// No exception is thrown during createWeightingParameters
assertAll(() -> CustomModelParser.createWeightingParameters(customModel, encodingManager, avgSpeedEnc, encoder.getMaxSpeed(), null));
CustomModel customModel2 = new CustomModel();
customModel2.setAreas(areas);
customModel2.addToSpeed(If("in_area_1", LIMIT, 100));
customModel2.addToSpeed(If("in_area_2", LIMIT, 25));
customModel2.addToSpeed(If("in_area_3", LIMIT, 150));
customModel2.addToSpeed(Else(LIMIT, 15));
assertThrows(IllegalArgumentException.class, () -> CustomModelParser.createWeightingParameters(customModel2, encodingManager, avgSpeedEnc, encoder.getMaxSpeed(), null));
}
use of com.graphhopper.util.CustomModel in project graphhopper by graphhopper.
the class RouteResourceCustomModelLMTest method createConfig.
private static GraphHopperServerConfiguration createConfig() {
GraphHopperServerConfiguration config = new GraphHopperServerTestConfiguration();
config.getGraphHopperConfiguration().putObject("graph.flag_encoders", "car,foot").putObject("datareader.file", "../core/files/andorra.osm.pbf").putObject("graph.location", DIR).putObject("graph.encoded_values", "surface").setProfiles(Arrays.asList(// give strange profile names to ensure that we do not mix vehicle and profile:
new CustomProfile("car_custom").setCustomModel(new CustomModel()).setVehicle("car"), new Profile("foot_profile").setVehicle("foot").setWeighting("fastest"), new CustomProfile("foot_custom").setCustomModel(new CustomModel()).setVehicle("foot"))).setLMProfiles(Arrays.asList(new LMProfile("car_custom"), new LMProfile("foot_custom")));
return config;
}
Aggregations