use of com.graphhopper.util.InstructionAnnotation in project PocketMaps by junjunguo.
the class TargetDirComputer method createTargetdirResponse.
public GHResponse createTargetdirResponse(double fromLat, double fromLon, double toLat, double toLon) {
GHResponse resp = new GHResponse();
PathWrapper pr = new PathWrapper();
PointList pl = new PointList();
pl.add(fromLat, fromLon);
pl.add(toLat, toLon);
pr.setPoints(pl);
double distance = GeoMath.fastDistance(fromLat, fromLon, toLat, toLon);
distance = distance * GeoMath.METER_PER_DEGREE;
pr.setDistance(distance);
double distKm = distance / 1000.0;
// 50km == 1h
double hours = distKm / 50;
if (Variable.getVariable().getTravelMode() == Variable.TravelMode.Bike) {
hours = hours * 3.0;
}
if (Variable.getVariable().getTravelMode() == Variable.TravelMode.Foot) {
hours = hours * 9.0;
}
long timeMs = (long) (hours * 60.0 * 60.0 * 1000.0);
pr.setTime(timeMs);
InstructionList insL = new InstructionList(createEmptyTranslator());
int sign = Instruction.CONTINUE_ON_STREET;
String name = "direction to target";
InstructionAnnotation ia = InstructionAnnotation.EMPTY;
Instruction ins = new Instruction(sign, name, ia, pl);
ins.setDistance(distance);
ins.setTime(timeMs);
insL.add(ins);
pr.setInstructions(insL);
resp.add(pr);
return resp;
}
Aggregations