Skip to content

Commit

Permalink
adding order to markers
Browse files Browse the repository at this point in the history
  • Loading branch information
berengerpro committed Apr 1, 2022
1 parent 62164c2 commit 0eda008
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/main/java/com/insa/coliffimo/router/RouterRunnable.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,22 @@ private void initMapView(RouteInfo route) {
shipmentInfoHashMap.put(shipment.getDeliveryLocation().getId(), new ShipmentInfo(color, ShipmentInfo.ShipmentType.DELIVERY));

LocalTime pickupTime = departureTime.plusSeconds((long) activityTime(route.tourActivities.get(0), shipment.getPickupLocation().getId()));
int pickupOrder = activityOrder(route.tourActivities.get(0), shipment.getPickupLocation().getId());
String pickupLabel = "Pickup</p><p>" +
shipment.getPickupLocation().getCoordinate().getX() + ", " +
shipment.getPickupLocation().getCoordinate().getY() + "</p><p>" +
"Arrivée : " + pickupTime.format(timeFormat) + "</p><p>" +
"Départ : " + pickupTime.plusSeconds((long) (shipment.getPickupServiceTime()/1000)).format(timeFormat);

LocalTime deliveryTime = departureTime.plusSeconds((long) activityTime(route.tourActivities.get(0), shipment.getDeliveryLocation().getId()));
int deliveryOrder = activityOrder(route.tourActivities.get(0), shipment.getDeliveryLocation().getId());
String deliveryLabel = "Delivery</p><p>" +
shipment.getDeliveryLocation().getCoordinate().getX() + ", " +
shipment.getDeliveryLocation().getCoordinate().getY() + "</p><p>" +
"Arrivée : " + deliveryTime.format(timeFormat) + "</p><p>" +
"Départ : " + deliveryTime.plusSeconds((long) (shipment.getDeliveryServiceTime()/1000)).format(timeFormat);
mapView.addMarker(from(shipment.getPickupLocation()), "Pickup", new PickupMarker(hex), 1, pickupLabel, "pickup" + idMarker);
mapView.addMarker(from(shipment.getDeliveryLocation()), "Delivery", new DeliveryMarker(hex), 1, deliveryLabel, "delivery" + idMarker);
mapView.addMarker(from(shipment.getPickupLocation()), "Pickup", new PickupMarker(hex, pickupOrder), 1, pickupLabel, "pickup" + idMarker);
mapView.addMarker(from(shipment.getDeliveryLocation()), "Delivery", new DeliveryMarker(hex, deliveryOrder), 1, deliveryLabel, "delivery" + idMarker);
k++;
}
double lastRouteTime = 0.0;
Expand Down Expand Up @@ -457,4 +459,15 @@ private double activityTime(TourActivities tourActivity, String id){
}
return 0.0;
}

private int activityOrder(TourActivities tourActivity, String id){
int i = 1;
for (TourActivity a : tourActivity.getActivities()){
if (a.getLocation().getId().equals(id)){
return i;
}
i++;
}
return 0;
}
}

0 comments on commit 0eda008

Please sign in to comment.