@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof RoadPath) { RoadPath that = (RoadPath) o; return (this.path.equals(that.getPath())) && (Double.doubleToLongBits(this.value) == Double.doubleToLongBits(that.getValue())) && (Double.doubleToLongBits(this.travelTime) == Double.doubleToLongBits(that.getTravelTime())); } return false; }
@Override public MoveProgress moveTo(MovingRoadUser object, Point destination, TimeLapse time, GeomHeuristic heuristic) { final Queue<Point> path; if (objDestinations.containsKey(object) && objDestinations.get(object).destination.equals(destination)) { // is valid move? -> assume it is path = objDestinations.get(object).path; } else { path = new LinkedList<>( getPathTo(object, destination, time.getTimeUnit(), Measure.valueOf(unitConversion.toExSpeed(object.getSpeed()), unitConversion.getExSpeedUnit()), heuristic).getPath()); objDestinations.put(object, new DestinationPath(destination, path)); } final MoveProgress mp = doFollowPath(object, path, time); eventDispatcher.dispatchEvent(new MoveEvent(self, object, mp)); return mp; }
@Override public RoadPath getPathTo(MovingRoadUser object, Point destination, Unit<Duration> timeUnit, Measure<Double, Velocity> maxSpeed, GeomHeuristic heuristic) { final Optional<? extends Connection<?>> conn = getConnection(object); if (conn.isPresent()) { final double connectionPercentage = Point.distance(getPosition(object), conn.get().to()) / Point.distance(conn.get().from(), conn.get().to()); final double cost = heuristic.calculateCost(graph, conn.get().from(), conn.get().to()) * connectionPercentage; final double travelTime = heuristic.calculateTravelTime(graph, conn.get().from(), conn.get().to(), getDistanceUnit(), maxSpeed, timeUnit) * connectionPercentage; final RoadPath path = getPathTo(conn.get().to(), destination, timeUnit, maxSpeed, heuristic); return RoadPath.create(path.getPath(), path.getValue() + cost, path.getTravelTime() + travelTime); } return getPathTo(getPosition(object), destination, timeUnit, maxSpeed, heuristic); }
maxSpeed, heuristic); final Measure<Double, Length> distance = snapshot.getDistanceOfPath(hp.getPath()); stats.totalDistance += distance.getValue(); final double tt = hp.getTravelTime(); maxSpeed, heuristic); final Measure<Double, Length> distance = snapshot.getDistanceOfPath(hp.getPath()); stats.totalDistance += distance.getValue(); final double tt = hp.getTravelTime();