Opersource Routing JAVA API

Hi everyone … I try using latest GH 6.2, and want to request using shortest weight

GraphHopper hopper = new GraphHopper();
		hopper.setOSMFile(osmFile);
		hopper.setGraphHopperLocation(graphHopperLocation);

		// see docs/core/profiles.md to learn more about profiles
		hopper.setProfiles(new Profile("car").setVehicle("car").setWeighting("shortest").setTurnCosts(false));

		// this enables speed mode for the profile we called car
		hopper.getCHPreparationHandler().setCHProfiles(new CHProfile("car"));

		if (closeAfterLoad)
			hopper.importAndClose();
		else
			hopper.importOrLoad();

And this is my GHRequest

GHRequest req = new GHRequest(originLatitude, originLongitude, destinationLatitude, destinationLongitude)
				.setAlgorithm(Parameters.Algorithms.DIJKSTRA_BI)
				.setProfile(vehicleProfile)
				.setLocale(Locale.ENGLISH);
		
		req.getHints().putObject("elevation", false);
		req.getHints().putObject(Parameters.Routing.INSTRUCTIONS, false);
		req.getHints().putObject(Parameters.Routing.CALC_POINTS, generateRoutePath);

I got this errors.
Speed cannot be 0 for unblocked edge, use access properties to mark edge blocked! Should only occur for shortest path calculation. See #242.

But after I change the weight to “fastest”, it’s running well. I taught that “shortest” weighting doesn’t need vehicle speed, but why I got this error ? There’s no documentation about that

I just ran into the same error, see this issue: Exception if speed is 0 but valid access flags and using shortest path algo. · Issue #242 · graphhopper/graphhopper · GitHub
It is true that the distance weighting doesn’t need to read the speed for the route calculation, because it only considers the distance. However, after the route is found we are still interested in the time that is needed to drive the route, for which we need to read the speed.

Wokayy, thankyou sir. Hopefully there will be updated soon for this bug.

Powered by Discourse