Hi everyone,
i´m new into Graphhopper
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) {
super(encoder);
this.nodeAccess=nodeAccess;
this.stations=stations;
}
@Override
public double getMinWeight(double distance) {
return 0;
}
@Override
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)))){
;
range=320000;
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
Sincerely,
BarinoNabar