|
@@ -58,9 +58,10 @@ public class MainController {
|
|
|
System.out.println(coordinates);
|
|
System.out.println(coordinates);
|
|
|
return coordinates;
|
|
return coordinates;
|
|
|
}
|
|
}
|
|
|
- @GetMapping("/optimize-delivery-route")
|
|
|
|
|
|
|
+
|
|
|
|
|
+ @RequestMapping("/optimize-delivery-route")
|
|
|
@ResponseBody
|
|
@ResponseBody
|
|
|
- public List<Coordinate> optimizeDeliveryRoute(List<Coordinate> coordinates) {
|
|
|
|
|
|
|
+ public List<Coordinate> optimizeDeliveryRoute(@RequestBody List<Coordinate> coordinates) {
|
|
|
|
|
|
|
|
List<Integer> optimizedRoute = new ArrayList<>();
|
|
List<Integer> optimizedRoute = new ArrayList<>();
|
|
|
List<Coordinate> optimizedRouteCoordinates = new ArrayList<>();
|
|
List<Coordinate> optimizedRouteCoordinates = new ArrayList<>();
|
|
@@ -93,10 +94,28 @@ public class MainController {
|
|
|
return optimizedRouteCoordinates;
|
|
return optimizedRouteCoordinates;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @RequestMapping("/intersections-between-multiple-coordinates")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public List<Coordinate> getIntersectionsBetweenCoordinates(@RequestBody List<Coordinate> coordinates) throws IOException {
|
|
|
|
|
+ List<Coordinate> optimizedRouteCoordinates = optimizeDeliveryRoute(coordinates);
|
|
|
|
|
+
|
|
|
|
|
+ ArrayList<Coordinate> nodes = new ArrayList<>();
|
|
|
|
|
+ for (int i = 0; i < optimizedRouteCoordinates.size(); i++) {
|
|
|
|
|
+ ArrayList<ArrayList<Double>> nodesBetweenTwoCoordinates;
|
|
|
|
|
+ if (i == optimizedRouteCoordinates.size() - 1) nodesBetweenTwoCoordinates = getNodesBetweenTwoCoordinates(optimizedRouteCoordinates.get(i).lon, optimizedRouteCoordinates.get(i).lat,optimizedRouteCoordinates.get(0).lon, optimizedRouteCoordinates.get(0).lat);
|
|
|
|
|
+ else nodesBetweenTwoCoordinates = getNodesBetweenTwoCoordinates(optimizedRouteCoordinates.get(i).lon, optimizedRouteCoordinates.get(i).lat,optimizedRouteCoordinates.get(i+1).lon, optimizedRouteCoordinates.get(i+1).lat);
|
|
|
|
|
+ System.out.println("Drop off");
|
|
|
|
|
+ for (ArrayList <Double> node: nodesBetweenTwoCoordinates) {
|
|
|
|
|
+ nodes.add(new Coordinate(node.get(0), node.get(1)));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return nodes;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private double calculateDistance(Coordinate c1, Coordinate c2) {
|
|
private double calculateDistance(Coordinate c1, Coordinate c2) {
|
|
|
ArrayList<ArrayList<Double>> nodes;
|
|
ArrayList<ArrayList<Double>> nodes;
|
|
|
try {
|
|
try {
|
|
|
- nodes = getNodesBetweenTwoCoordinates(c1.lat, c1.lon, c2.lat, c2.lon);
|
|
|
|
|
|
|
+ nodes = getNodesBetweenTwoCoordinates(c1.lon, c1.lat, c2.lon, c2.lat);
|
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
return Double.MAX_VALUE;
|
|
return Double.MAX_VALUE;
|