Initial load for GoogleMaps done
This commit is contained in:
@@ -7,6 +7,7 @@ public class FlightPath {
|
||||
private ArrayList<FlightPoint> flightPoints;
|
||||
private String departureAirport;
|
||||
private String arrivalAirport;
|
||||
private RoutePath routePath;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -88,4 +89,14 @@ public class FlightPath {
|
||||
this.flightPoints.add(flightPoints.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public RoutePath getRoutePath(){
|
||||
if (routePath == null){
|
||||
routePath = new RoutePath();
|
||||
for (FlightPoint point: flightPoints){
|
||||
routePath.addPosition(new Position(point.getLatitude(), point.getLongitude()));
|
||||
}
|
||||
}
|
||||
return routePath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package seng202.group9.Core;
|
||||
|
||||
/**
|
||||
* Created by fwy13 on 17/09/16.
|
||||
*/
|
||||
public class Position {
|
||||
public double lat;
|
||||
public double lng;
|
||||
|
||||
public Position(double lat, double lng) {
|
||||
this.lat = lat;
|
||||
this.lng = lng;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ public class Route {
|
||||
private Airport sourceAirport;
|
||||
private Airport destinationAirport;
|
||||
private Airline airline = null;
|
||||
private RoutePath routePath = null;
|
||||
|
||||
/**
|
||||
* Constructor for pulling from database
|
||||
@@ -246,6 +247,17 @@ public class Route {
|
||||
throw new DataException("This Route already exists.");
|
||||
}
|
||||
}
|
||||
|
||||
public RoutePath getRoutePath(){
|
||||
if (routePath == null) {
|
||||
routePath = new RoutePath(
|
||||
new Position(getSourceAirport().getLatitude(), getSourceAirport().getLongitude()),
|
||||
new Position(getDestinationAirport().getLatitude(), getDestinationAirport().getLongitude())
|
||||
);
|
||||
}
|
||||
return routePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(){
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package seng202.group9.Core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Created by brad on 9/09/16.
|
||||
* Edited by fwy13
|
||||
*/
|
||||
public class RoutePath {
|
||||
private ArrayList<Position> route = new ArrayList<Position>();
|
||||
|
||||
public RoutePath(Position ...points) {
|
||||
Collections.addAll(route, points);
|
||||
}
|
||||
|
||||
public RoutePath(){
|
||||
|
||||
}
|
||||
|
||||
public void addPosition(Position position){
|
||||
route.add(position);
|
||||
}
|
||||
|
||||
public String toJSONArray() {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append("[");
|
||||
for (Position pos : route){
|
||||
stringBuilder.append(
|
||||
String.format("{lat: %f, lng: %f}, ", pos.lat, pos.lng));
|
||||
}
|
||||
stringBuilder.append("]");
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user