Search in sources :

Example 6 with GraphHopperConfig

use of com.graphhopper.GraphHopperConfig in project OTN by L-Belluomini.

the class OTNMapComponent method getGraphFromDir.

protected OTNGraph getGraphFromDir(String dir) {
    GraphHopperConfig tmpConfig = null;
    try {
        Gson ason = new Gson();
        FileReader fReader = new FileReader(FileSystemUtils.getItem(FileSystemUtils.TOOL_DATA_DIRECTORY + "/OTN/graphs/" + dir + "/config.json"));
        JsonReader reader = new JsonReader(fReader);
        tmpConfig = ason.fromJson(reader, GraphHopperConfig.class);
        if (tmpConfig == null) {
            Log.w(TAG, "reading j config failed");
            return null;
        }
    } catch (Exception e) {
        Log.e(TAG, "An error occurred, reading ");
        Log.e(TAG, e.toString());
    }
    return new OTNGraph("/OTN/graphs/" + dir, tmpConfig);
}
Also used : Gson(com.google.gson.Gson) JsonReader(com.google.gson.stream.JsonReader) FileReader(java.io.FileReader) GraphHopperConfig(com.graphhopper.GraphHopperConfig)

Example 7 with GraphHopperConfig

use of com.graphhopper.GraphHopperConfig in project graphhopper by graphhopper.

the class MiniGraphUI method main.

public static void main(String[] strs) {
    PMap args = PMap.read(strs);
    args.putObject("datareader.file", args.getString("datareader.file", "core/files/monaco.osm.gz"));
    args.putObject("graph.location", args.getString("graph.location", "tools/target/mini-graph-ui-gh"));
    args.putObject("graph.flag_encoders", args.getString("graph.flag_encoders", "car"));
    GraphHopperConfig ghConfig = new GraphHopperConfig(args);
    ghConfig.setProfiles(Arrays.asList(new Profile("profile").setVehicle("car").setWeighting("fastest")));
    ghConfig.setCHProfiles(Arrays.asList(new CHProfile("profile")));
    ghConfig.setLMProfiles(Arrays.asList(new LMProfile("profile")));
    GraphHopper hopper = new GraphHopper().init(ghConfig).importOrLoad();
    boolean debug = args.getBool("minigraphui.debug", false);
    boolean useCH = args.getBool("minigraphui.useCH", false);
    new MiniGraphUI(hopper, debug, useCH).visualize();
}
Also used : CHProfile(com.graphhopper.config.CHProfile) PMap(com.graphhopper.util.PMap) LMProfile(com.graphhopper.config.LMProfile) GraphHopper(com.graphhopper.GraphHopper) Profile(com.graphhopper.config.Profile) CHProfile(com.graphhopper.config.CHProfile) LMProfile(com.graphhopper.config.LMProfile) GraphHopperConfig(com.graphhopper.GraphHopperConfig)

Aggregations

GraphHopperConfig (com.graphhopper.GraphHopperConfig)7 GraphHopper (com.graphhopper.GraphHopper)4 Profile (com.graphhopper.config.Profile)4 CHProfile (com.graphhopper.config.CHProfile)3 LMProfile (com.graphhopper.config.LMProfile)3 PMap (com.graphhopper.util.PMap)2 Test (org.junit.jupiter.api.Test)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 XmlMapper (com.fasterxml.jackson.dataformat.xml.XmlMapper)1 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)1 Gson (com.google.gson.Gson)1 JsonReader (com.google.gson.stream.JsonReader)1 ResponsePath (com.graphhopper.ResponsePath)1 Gpx (com.graphhopper.jackson.Gpx)1 MapMatching (com.graphhopper.matching.MapMatching)1 MatchResult (com.graphhopper.matching.MatchResult)1 Observation (com.graphhopper.matching.Observation)1 CountryRuleFactory (com.graphhopper.routing.util.countryrules.CountryRuleFactory)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1