Request createGetRequest(GHRequest ghRequest) {
        if (ghRequest.getCustomModel() != null)
            throw new IllegalArgumentException("Custom models cannot be used for GET requests. Use setPostRequest(true)");

        boolean tmpInstructions = ghRequest.getHints().getBool(INSTRUCTIONS, instructions);
        boolean tmpCalcPoints = ghRequest.getHints().getBool(CALC_POINTS, calcPoints);
        String tmpOptimize = ghRequest.getHints().getString("optimize", optimize);

        if (tmpInstructions && !tmpCalcPoints) {
            throw new IllegalStateException("Cannot calculate instructions without points (only points without instructions). "
                    + "Use calc_points=false and instructions=false to disable point and instruction calculation");
        }

        boolean tmpElevation = ghRequest.getHints().getBool("elevation", elevation);

        String places = "";
        for (GHPoint p : ghRequest.getPoints()) {
            places += "&point=" + round6(p.lat) + "," + round6(p.lon);
        }

        String type = ghRequest.getHints().getString("type", "json");

        String url = routeServiceUrl
                + "?"
                + "profile=" + ghRequest.getProfile()
                + places
                + "&type=" + type
                + "&instructions=" + tmpInstructions
                + "&points_encoded=true"
                + "&points_encoded_multiplier=1000000"
                + "&calc_points=" + tmpCalcPoints
                + "&algorithm=" + ghRequest.getAlgorithm()
                + "&locale=" + ghRequest.getLocale().toString()
                + "&elevation=" + tmpElevation
                + "&optimize=" + tmpOptimize;

        for (String details : ghRequest.getPathDetails()) {
            url += "&" + Parameters.Details.PATH_DETAILS + "=" + encodeURL(details);
        }

        // append *all* point hints if at least one is not empty
        if (ghRequest.getPointHints().stream().anyMatch(h -> !h.isEmpty()))
            for (String hint : ghRequest.getPointHints())
                url += "&" + Parameters.Routing.POINT_HINT + "=" + encodeURL(hint);


        // append *all* curbsides if at least one is not empty
        if (ghRequest.getCurbsides().stream().anyMatch(c -> !c.isEmpty()))
            for (String curbside : ghRequest.getCurbsides())
                url += "&" + Parameters.Routing.CURBSIDE + "=" + encodeURL(curbside);

        // append *all* headings only if at least *one* is not NaN
        if (ghRequest.getHeadings().stream().anyMatch(h -> !Double.isNaN(h)))
            for (Double heading : ghRequest.getHeadings())
                url += "&heading=" + heading;


        for (String snapPrevention : ghRequest.getSnapPreventions()) {
            url += "&" + Parameters.Routing.SNAP_PREVENTION + "=" + encodeURL(snapPrevention);
        }

        if (!key.isEmpty()) {
            url += "&key=" + encodeURL(key);
        }

        for (Map.Entry<String, Object> entry : ghRequest.getHints().toMap().entrySet()) {
            String urlKey = entry.getKey();
            String urlValue = entry.getValue().toString();

            // use lower case conversion for check only!
            if (ignoreSetForGet.contains(toLowerCase(urlKey))) {
                continue;
            }

            if (urlValue != null && !urlValue.isEmpty()) {
                url += "&" + encodeURL(urlKey) + "=" + encodeURL(urlValue);
            }
        }

        return new Request.Builder().url(url)
                .header(X_GH_CLIENT_VERSION, GH_VERSION_FROM_MAVEN)
                .build();
    }
@Test
    public void headings() {
        GraphHopperWeb hopper = new GraphHopperWeb("http://localhost:8080/route");
        GHRequest req = new GHRequest(new GHPoint(42.509225, 1.534728), new GHPoint(42.512602, 1.551558)).
                setHeadings(Arrays.asList(10.0, 90.0)).
                setProfile("car");
        assertEquals("http://localhost:8080/route?profile=car&point=42.509225,1.534728&point=42.512602,1.551558&type=json&instructions=true&points_encoded=true&points_encoded_multiplier=1000000" +
                "&calc_points=true&algorithm=&locale=en_US&elevation=false&optimize=false&heading=10.0&heading=90.0", hopper.createGetRequest(req).url().toString());
    }