Calc Route with Chargingstations for ev (approach)

Hi everyone,
i´m new into Graphhopper :confused:
I would like to calculate the Route for electric vehicles with considering chargingstations. For example , the Route between Paris and Berlin is 1000 km long. The electric vehicle can drive 400 km without charging. So after 400 km the vehicle must reach a charging station. My approach is to mark the position of the chargingstation into the weighting. How can i mark a node as chargingstation?

double range = 400000;
NodeAccess nodeAccess;
HashedMap<Point,ChargingStation> stations;

protected CustomWeighting(FlagEncoder encoder,NodeAccess nodeAccess,HashedMap<Point,ChargingStation> stations) {

public double getMinWeight(double distance) {
    return 0;

public double calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId) {
    if (range >= 80000) { //20% of range
        range -= edgeState.getDistance();
        return edgeState.getDistance();
    } else {
        if(stations.containsKey(new Point(nodeAccess.getLatitude(prevOrNextEdgeId),nodeAccess.getLongitude(prevOrNextEdgeId)))){ 
            return edgeState.getDistance();
    return Double.POSITIVE_INFINITY ;

I don´t know if this is a good approach. If someone has a better approach for this problem, i would be very thankful to hear it.

Sorry for my bad english :confused:



This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.

Powered by Discourse