Finished Google Maps API
This commit is contained in:
Binary file not shown.
@@ -326,8 +326,8 @@ public class Dataset {
|
|||||||
"`Heading` TEXT, " +
|
"`Heading` TEXT, " +
|
||||||
"`Altitude` INTEGER, " +
|
"`Altitude` INTEGER, " +
|
||||||
"`Tot_Dist` INTEGER, " +
|
"`Tot_Dist` INTEGER, " +
|
||||||
"`Longitude` REAL, " +
|
|
||||||
"`Latitude` REAL, " +
|
"`Latitude` REAL, " +
|
||||||
|
"`Longitude` REAL, " +
|
||||||
"`Leg_Dist` INTEGER, " +
|
"`Leg_Dist` INTEGER, " +
|
||||||
"`Order` INTEGER)";
|
"`Order` INTEGER)";
|
||||||
stmt.execute(createFlightPointTable);
|
stmt.execute(createFlightPointTable);
|
||||||
@@ -689,7 +689,7 @@ public class Dataset {
|
|||||||
flightPathToAdd.setID(flightPathId);
|
flightPathToAdd.setID(flightPathId);
|
||||||
//ADDED
|
//ADDED
|
||||||
String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," +
|
String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," +
|
||||||
" `Altitude`, `Longitude`, `Latitude`) VALUES ";
|
" `Altitude`, `Latitude`, `Longitude`) VALUES ";
|
||||||
int numOfFlights = 0;
|
int numOfFlights = 0;
|
||||||
for (int i = 0; i < flightPointsToImport.size(); i ++){
|
for (int i = 0; i < flightPointsToImport.size(); i ++){
|
||||||
String flightPointIdentifier = flightPointsToImport.get(i).getType() + flightPointsToImport.get(i).getName() +
|
String flightPointIdentifier = flightPointsToImport.get(i).getType() + flightPointsToImport.get(i).getName() +
|
||||||
@@ -1076,7 +1076,7 @@ public class Dataset {
|
|||||||
|
|
||||||
stmt = c.createStatement();
|
stmt = c.createStatement();
|
||||||
String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," +
|
String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," +
|
||||||
" `Altitude`, `Longitude`, `Latitude`, `Heading`, `Tot_Dist`, `Leg_Dist`, `Via`) VALUES ";
|
" `Altitude`, `Latitude`, `Longitude`, `Heading`, `Tot_Dist`, `Leg_Dist`, `Via`) VALUES ";
|
||||||
String flightType = type.replace("\"", "\"\"");
|
String flightType = type.replace("\"", "\"\"");
|
||||||
String flightName = name.replace("\"", "\"\"");
|
String flightName = name.replace("\"", "\"\"");
|
||||||
insertFlightPointQuery += "(" + id +", \""+ flightName +"\", \"" + flightType + "\", "+ altitudeVal + ", " +
|
insertFlightPointQuery += "(" + id +", \""+ flightName +"\", \"" + flightType + "\", "+ altitudeVal + ", " +
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ public class FlightPath {
|
|||||||
private ArrayList<FlightPoint> flightPoints;
|
private ArrayList<FlightPoint> flightPoints;
|
||||||
private String departureAirport;
|
private String departureAirport;
|
||||||
private String arrivalAirport;
|
private String arrivalAirport;
|
||||||
private RoutePath routePath;
|
final private RoutePath routePath = new RoutePath();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -91,8 +91,7 @@ public class FlightPath {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RoutePath getRoutePath(){
|
public RoutePath getRoutePath(){
|
||||||
if (routePath == null){
|
if (routePath.getRoute().size() == 0){
|
||||||
routePath = new RoutePath();
|
|
||||||
for (FlightPoint point: flightPoints){
|
for (FlightPoint point: flightPoints){
|
||||||
routePath.addPosition(new Position(point.getLatitude(), point.getLongitude()));
|
routePath.addPosition(new Position(point.getLatitude(), point.getLongitude()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ public class RoutePath {
|
|||||||
route.add(position);
|
route.add(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<Position> getRoute() {
|
||||||
|
return route;
|
||||||
|
}
|
||||||
|
|
||||||
public String toJSONArray() {
|
public String toJSONArray() {
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
stringBuilder.append("[");
|
stringBuilder.append("[");
|
||||||
@@ -32,4 +36,5 @@ public class RoutePath {
|
|||||||
stringBuilder.append("]");
|
stringBuilder.append("]");
|
||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
package seng202.group9.GUI;
|
package seng202.group9.GUI;
|
||||||
|
|
||||||
|
import javafx.beans.value.ChangeListener;
|
||||||
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
@@ -11,6 +13,7 @@ import seng202.group9.Controller.App;
|
|||||||
import seng202.group9.Controller.Dataset;
|
import seng202.group9.Controller.Dataset;
|
||||||
import seng202.group9.Controller.SceneCode;
|
import seng202.group9.Controller.SceneCode;
|
||||||
import seng202.group9.Core.FlightPath;
|
import seng202.group9.Core.FlightPath;
|
||||||
|
import seng202.group9.Core.RoutePath;
|
||||||
import seng202.group9.Map.Map;
|
import seng202.group9.Map.Map;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -68,7 +71,16 @@ public class FlightSummaryController extends Controller {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
map = new Map(mapView);
|
if (theDataSet.getFlightPaths().size() > 0){
|
||||||
|
map = new Map(mapView, theDataSet.getFlightPaths().get(0).getRoutePath());
|
||||||
|
}else{
|
||||||
|
map = new Map(mapView, new RoutePath());
|
||||||
|
}
|
||||||
|
flightPathListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
|
||||||
|
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
|
||||||
|
map.displayRoute(theDataSet.getFlightPaths().get(flightPathListView.getSelectionModel().getSelectedIndices().get(0)).getRoutePath());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,25 +15,29 @@ public class Map {
|
|||||||
|
|
||||||
private WebEngine webEngine;
|
private WebEngine webEngine;
|
||||||
private WebView webView;
|
private WebView webView;
|
||||||
|
private boolean canLoad = false;
|
||||||
|
|
||||||
public Map(WebView webView){
|
public Map(WebView webView, final RoutePath newRoute){
|
||||||
this.webView = webView;
|
this.webView = webView;
|
||||||
webEngine = webView.getEngine();
|
webEngine = webView.getEngine();
|
||||||
initMap();
|
initMap();
|
||||||
|
webEngine.getLoadWorker().stateProperty().addListener(
|
||||||
|
new ChangeListener<Worker.State>() {
|
||||||
|
public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) {
|
||||||
|
if (newState == Worker.State.SUCCEEDED){
|
||||||
|
displayRoute(newRoute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initMap() {
|
public void initMap() {
|
||||||
webEngine.load(getClass().getClassLoader().getResource("map.html").toExternalForm());
|
webEngine.load(getClass().getClassLoader().getResource("map.html").toExternalForm());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayRoute(final RoutePath newRoute) {
|
public void displayRoute(RoutePath newRoute) {
|
||||||
webEngine.getLoadWorker().stateProperty().addListener(
|
|
||||||
new ChangeListener<Worker.State>(){
|
|
||||||
public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState){
|
|
||||||
String scriptToExecute = "displayRoute(" + newRoute.toJSONArray() + ");";
|
String scriptToExecute = "displayRoute(" + newRoute.toJSONArray() + ");";
|
||||||
webEngine.executeScript(scriptToExecute);
|
webEngine.executeScript(scriptToExecute);
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,6 +36,19 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function displayAirport(position){
|
||||||
|
map = new google.maps.Map(document.getElementById('map'), {
|
||||||
|
center: position[0],
|
||||||
|
zoom: 15
|
||||||
|
});
|
||||||
|
|
||||||
|
new google.maps.Marker({
|
||||||
|
position: position[0],
|
||||||
|
map: map,
|
||||||
|
title: '\u0048\u0061\u0072\u0061\u006d\u0062\u0065'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function displayRoute(flightPath) {
|
function displayRoute(flightPath) {
|
||||||
// CLEAR EXISTING MARKERS
|
// CLEAR EXISTING MARKERS
|
||||||
if (marker1 !== undefined && marker2 !== undefined && path !== undefined) {
|
if (marker1 !== undefined && marker2 !== undefined && path !== undefined) {
|
||||||
|
|||||||
Reference in New Issue
Block a user