From 0eda008c0439dc149e093165326968c5fad3a338 Mon Sep 17 00:00:00 2001 From: berengerpro Date: Fri, 1 Apr 2022 12:56:38 +0100 Subject: [PATCH] adding order to markers --- .../insa/coliffimo/router/RouterRunnable.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/insa/coliffimo/router/RouterRunnable.java b/src/main/java/com/insa/coliffimo/router/RouterRunnable.java index 520137c..08f492e 100644 --- a/src/main/java/com/insa/coliffimo/router/RouterRunnable.java +++ b/src/main/java/com/insa/coliffimo/router/RouterRunnable.java @@ -159,6 +159,7 @@ 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

" + shipment.getPickupLocation().getCoordinate().getX() + ", " + shipment.getPickupLocation().getCoordinate().getY() + "

" + @@ -166,13 +167,14 @@ private void initMapView(RouteInfo route) { "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

" + shipment.getDeliveryLocation().getCoordinate().getX() + ", " + shipment.getDeliveryLocation().getCoordinate().getY() + "

" + "Arrivée : " + deliveryTime.format(timeFormat) + "

" + "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; @@ -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; + } }