public GraphHopperManaged(CmdArgs configuration, ObjectMapper objectMapper) {
String splitAreaLocation = configuration.get(Parameters.Landmark.PREPARE + "split_area_location", "");
JsonFeatureCollection landmarkSplittingFeatureCollection;
try (Reader reader = splitAreaLocation.isEmpty() ? new InputStreamReader(LandmarkStorage.class.getResource("map.geo.json").openStream(), UTF_CS) : new InputStreamReader(new FileInputStream(splitAreaLocation), UTF_CS)) {
landmarkSplittingFeatureCollection = objectMapper.readValue(reader, JsonFeatureCollection.class);
} catch (IOException e1) {
logger.error("Problem while reading border map GeoJSON. Skipping this.", e1);
landmarkSplittingFeatureCollection = null;
}
graphHopper = new GraphHopperOSM(landmarkSplittingFeatureCollection).forServer();
String spatialRuleLocation = configuration.get("spatial_rules.location", "");
if (!spatialRuleLocation.isEmpty()) {
final BBox maxBounds = BBox.parseBBoxString(configuration.get("spatial_rules.max_bbox", "-180, 180, -90, 90"));
try (final InputStreamReader reader = new InputStreamReader(new FileInputStream(spatialRuleLocation), UTF_CS)) {
JsonFeatureCollection jsonFeatureCollection = objectMapper.readValue(reader, JsonFeatureCollection.class);
SpatialRuleLookupHelper.buildAndInjectSpatialRuleIntoGH(graphHopper, maxBounds, jsonFeatureCollection);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
graphHopper.init(configuration);
}