use of com.graphhopper.storage.StorableProperties in project graphhopper by graphhopper.
the class InfoServlet method doGet.
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
BBox bb = storage.getBounds();
List<Double> list = new ArrayList<>(4);
list.add(bb.minLon);
list.add(bb.minLat);
list.add(bb.maxLon);
list.add(bb.maxLat);
final JsonNodeFactory jsonNodeFactory = new JsonNodeFactory(false);
final ObjectNode json = jsonNodeFactory.objectNode();
json.putPOJO("bbox", list);
String[] vehicles = storage.getEncodingManager().toString().split(",");
json.putPOJO("supported_vehicles", vehicles);
ObjectNode features = json.putObject("features");
for (String v : vehicles) {
ObjectNode perVehicleJson = features.putObject(v);
perVehicleJson.put("elevation", hasElevation);
}
json.put("version", Constants.VERSION);
json.put("build_date", Constants.BUILD_DATE);
StorableProperties props = storage.getProperties();
json.put("import_date", props.get("datareader.import.date"));
if (!Helper.isEmpty(props.get("datareader.data.date")))
json.put("data_date", props.get("datareader.data.date"));
String tmpDate = props.get(Parameters.CH.PREPARE + "date");
if (!Helper.isEmpty(tmpDate)) {
json.put("prepare_ch_date", tmpDate);
json.put("prepare_date", tmpDate);
}
writeJson(req, res, json);
}
use of com.graphhopper.storage.StorableProperties in project graphhopper by graphhopper.
the class EncodingManager method create.
/**
* Create the EncodingManager from the provided GraphHopper location. Throws an
* IllegalStateException if it fails. Used if no EncodingManager specified on load.
*/
public static EncodingManager create(FlagEncoderFactory factory, String ghLoc) {
Directory dir = new RAMDirectory(ghLoc, true);
StorableProperties properties = new StorableProperties(dir);
if (!properties.loadExisting())
throw new IllegalStateException("Cannot load properties to fetch EncodingManager configuration at: " + dir.getLocation());
// check encoding for compatibility
properties.checkVersions(false);
String acceptStr = properties.get("graph.flag_encoders");
if (acceptStr.isEmpty())
throw new IllegalStateException("EncodingManager was not configured. And no one was found in the graph: " + dir.getLocation());
int bytesForFlags = 4;
if ("8".equals(properties.get("graph.bytes_for_flags")))
bytesForFlags = 8;
return new EncodingManager(factory, acceptStr, bytesForFlags);
}
Aggregations