public class ShortestEasyWeighting extends ShortestWeighting {
protected double maxSpeed;
protected double routingPriority;
public ShortestEasyWeighting(FlagEncoder encoder) {
this.flagEncoder = encoder;
maxSpeed = encoder.getMaxSpeed();
routingPriority = encoder.getRoutingPriority();
}
@Override
public double getMinWeight(double currDistToGoal) {
return currDistToGoal;
}
//@Override
public double calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId) {
return edgeState.getDistance / (maxSpeed * routingPriority);
}
@Override
public String getName() {
return "short_easy";
}
}
These are the errors I am getting:
[ERROR] /home/t4a/Downloads/graphhopper-4.x/core/src/main/java/com/graphhopper/routing/weighting/ShortestEasyWeighting.java:[39,54] error: no suitable constructor found for ShortestWeighting(no arguments)
[ERROR] constructor ShortestWeighting.ShortestWeighting(FlagEncoder) is not applicable
[ERROR] (actual and formal argument lists differ in length)
[ERROR] constructor ShortestWeighting.ShortestWeighting(FlagEncoder,TurnCostProvider) is not applicable
[ERROR] (actual and formal argument lists differ in length)
[ERROR] /home/t4a/Downloads/graphhopper-4.x/core/src/main/java/com/graphhopper/routing/weighting/ShortestEasyWeighting.java:[41,12] error: cannot assign a value to final variable flagEncoder
[ERROR] /home/t4a/Downloads/graphhopper-4.x/core/src/main/java/com/graphhopper/routing/weighting/ShortestEasyWeighting.java:[43,33] error: cannot find symbol
[ERROR] symbol: method getRoutingPriority()
[ERROR] location: variable encoder of type FlagEncoder
[ERROR] /home/t4a/Downloads/graphhopper-4.x/core/src/main/java/com/graphhopper/routing/weighting/ShortestEasyWeighting.java:[55,24] error: cannot find symbol
[ERROR] symbol: variable getDistance
Any suggestions how I can achieve this would be greatly appreciated.
public class ShortestEasyWeighting extends ShortestWeighting {
protected double maxSpeed;
protected double routingPriority;
public ShortestEasyWeighting(FlagEncoder flagEncoder) {
super(flagEncoder);
// maxSpeed = encoder.getMaxSpeed();
// routingPriority = encoder.getRoutingPriority();
}
@Override
public double getMinWeight(double currDistToGoal) {
return currDistToGoal;
}
//@Override
public double calcWeight(EdgeIteratorState edgeState, boolean reverse, int prevOrNextEdgeId) {
//return edgeState.getDistance();
return edgeState.getDistance() / (maxSpeed * routingPriority);
}
@Override
public String getName() {
return "short_easy";
}
}
However, I get this error when executing a GraphHopper instance:
2021-11-30 15:35:47.799 [main] ERROR io.dropwizard.cli.ServerCommand - Unable to start server, shutting down
java.lang.IllegalArgumentException: Could not create weighting for profile: ‘my_custom_car’.
Profile: name=my_custom_car|vehicle=car|weighting=short_easy|turnCosts=false|hints={distance_factor=0}
Error: Weighting ‘short_easy’ not supported
at com.graphhopper.GraphHopper.checkProfilesConsistency(GraphHopper.java:845)
at com.graphhopper.GraphHopper.load(GraphHopper.java:787)
at com.graphhopper.GraphHopper.importOrLoad(GraphHopper.java:633)
at com.graphhopper.http.GraphHopperManaged.start(GraphHopperManaged.java:103)
at io.dropwizard.lifecycle.JettyManaged.doStart(JettyManaged.java:27)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
at org.eclipse.jetty.server.Server.start(Server.java:423)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
at org.eclipse.jetty.server.Server.doStart(Server.java:387)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
at io.dropwizard.cli.ServerCommand.run(ServerCommand.java:53)
at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:60)
at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:98)
at io.dropwizard.cli.Cli.run(Cli.java:78)
at io.dropwizard.Application.run(Application.java:94)
at com.graphhopper.http.GraphHopperApplication.main(GraphHopperApplication.java:35)
java.lang.IllegalArgumentException: Could not create weighting for profile: ‘my_custom_car’. Profile: name=my_custom_car|vehicle=car|weighting=short_easy|turnCosts=false|hints={distance_factor=0} Error: Weighting ‘short_easy’ not supported
at com.graphhopper.GraphHopper.checkProfilesConsistency(GraphHopper.java:845)
at com.graphhopper.GraphHopper.load(GraphHopper.java:787)
at com.graphhopper.GraphHopper.importOrLoad(GraphHopper.java:633)
at com.graphhopper.http.GraphHopperManaged.start(GraphHopperManaged.java:103)
at io.dropwizard.lifecycle.JettyManaged.doStart(JettyManaged.java:27)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:169)
at org.eclipse.jetty.server.Server.start(Server.java:423)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:117)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:97)
at org.eclipse.jetty.server.Server.doStart(Server.java:387)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:73)
at io.dropwizard.cli.ServerCommand.run(ServerCommand.java:53)
at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:60)
at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:98)
at io.dropwizard.cli.Cli.run(Cli.java:78)
at io.dropwizard.Application.run(Application.java:94)
at com.graphhopper.http.GraphHopperApplication.main(GraphHopperApplication.java:35)