RoundTrip Alternatives?

Is it possible for RoundTrip several alternatives to get?

roundTripPathWrappers.size()>0) >>> Is always one

Or do I have to change SEED/HEADING and always generate a track…

//----- Round Trip Test

    GHRequest rq = new GHRequest().
            addPoint(new GHPoint(48.9167, 8.7833)).
            setVehicle(vehicle).setWeighting("fastest").setAlgorithm(Parameters.Algorithms.ROUND_TRIP);
    rq.getHints().put(Parameters.Algorithms.RoundTrip.HEADING, 50);
    rq.getHints().put(Parameters.Algorithms.RoundTrip.DISTANCE, 50000);
    rq.getHints().put(Parameters.Algorithms.RoundTrip.SEED,0);
    rsp = hopper.route(rq); //Todo instance ändern to hopper
    PathWrapper pw = rsp.getBest();
    System.out.println("Round Trip Distance: "+rsp.getBest().getDistance() / 1000f);
    System.out.println("Round Trip     Time: "+rsp.getBest().getTime() / 1000f / 60);
    System.out.println("Round Trip    Points: "+pw.getPoints().size());;
    List<PathWrapper> roundTripPathWrappers=rsp.getAll();
    if(roundTripPathWrappers.size()>0) {
        int count = 0;
        for (PathWrapper pathWrapper : roundTripPathWrappers) {
        
        ......do work
        }
    }

This should be possible somehow, see AlternativeRoutingTemplate.isReady. You’ll need to add multiple altResponses to ghResponse ghResponse.add(altResponse); and before that fill every altResponse via the pathMerger pathMerger.doWork(altResponse, pathList, tr);

Sorry, but I can not make alternative roundtrip tracks to generate. I know to the Hopper Framwerk too little.
My goal is to generate as 5 roundtrip Gpx Tracks. But only the first track is ok, the other instruction lists are null.
Can anybody help me?

Thanks
Achim

My CodeSnipped:

        PathWrapper altResponse = new PathWrapper();
        altResponse.setWaypoints(wpList);
        for (int i = 0; i < 5; i++) {
            rsp.add(altResponse);
            iL = rsp.getAll().get(i).getInstructions();
            gpx = iL.createGPX("RoundTrip Graphhopper_GPX", 0l, true, false, true, true);
            try {
                writeUTF8TextFileContent("e:/gh/RoundTrip/GH_RoundTrip_" + i + ".gpx", gpx);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

This is not implemented as creating a round trip on its own is rather resource expensive. I made the proposal to implement this on your own using the snippets in the alternative template. But have not tried it myself. Maybe @boldtrn can help or has tried this already?

Yes this is possible and shouldn’t be much overhead. I tried if for Kurviger and it’s possible. I think it was pretty straight forward. I think I started in the round trip template and extend from there. Unfortunately, I do not have a sample ready right now.

Kurviger that’s what I strive but just for foot/bik2 and with other alternatives…:wink:

1 Like

Hi,
it is possible in the meantime to generate alternative round trip routes?

If so, how can I create it?

Many thanks
Achim