Merge remote-tracking branch 'origin/master'
# Conflicts: # src/main/java/seng202/group9/GUI/FlightSummaryController.java
This commit is contained in:
@@ -326,8 +326,8 @@ public class Dataset {
|
||||
"`Heading` TEXT, " +
|
||||
"`Altitude` INTEGER, " +
|
||||
"`Tot_Dist` INTEGER, " +
|
||||
"`Longitude` REAL, " +
|
||||
"`Latitude` REAL, " +
|
||||
"`Longitude` REAL, " +
|
||||
"`Leg_Dist` INTEGER, " +
|
||||
"`Order` INTEGER)";
|
||||
stmt.execute(createFlightPointTable);
|
||||
@@ -689,7 +689,7 @@ public class Dataset {
|
||||
flightPathToAdd.setID(flightPathId);
|
||||
//ADDED
|
||||
String insertFlightPointQuery = "INSERT INTO `" + this.name + "_Flight_Points` (`Index_ID`, `Name`, `Type`," +
|
||||
" `Altitude`, `Longitude`, `Latitude`) VALUES ";
|
||||
" `Altitude`, `Latitude`, `Longitude`) VALUES ";
|
||||
int numOfFlights = 0;
|
||||
for (int i = 0; i < flightPointsToImport.size(); i ++){
|
||||
String flightPointIdentifier = flightPointsToImport.get(i).getType() + flightPointsToImport.get(i).getName() +
|
||||
@@ -1120,7 +1120,7 @@ public class Dataset {
|
||||
|
||||
stmt = c.createStatement();
|
||||
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 flightName = name.replace("\"", "\"\"");
|
||||
insertFlightPointQuery += "(" + id +", \""+ flightName +"\", \"" + flightType + "\", "+ altitudeVal + ", " +
|
||||
|
||||
@@ -7,6 +7,7 @@ public class FlightPath {
|
||||
private ArrayList<FlightPoint> flightPoints;
|
||||
private String departureAirport;
|
||||
private String arrivalAirport;
|
||||
final private RoutePath routePath = new RoutePath();
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -88,4 +89,13 @@ public class FlightPath {
|
||||
this.flightPoints.add(flightPoints.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public RoutePath getRoutePath(){
|
||||
if (routePath.getRoute().size() == 0){
|
||||
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,40 @@
|
||||
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 ArrayList<Position> getRoute() {
|
||||
return route;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package seng202.group9.GUI;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.EventHandler;
|
||||
@@ -8,10 +10,13 @@ import javafx.fxml.Initializable;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ListView;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.web.WebView;
|
||||
import seng202.group9.Controller.App;
|
||||
import seng202.group9.Controller.Dataset;
|
||||
import seng202.group9.Controller.SceneCode;
|
||||
import seng202.group9.Core.FlightPath;
|
||||
import seng202.group9.Core.RoutePath;
|
||||
import seng202.group9.Map.Map;
|
||||
import seng202.group9.Core.FlightPoint;
|
||||
|
||||
import java.net.URL;
|
||||
@@ -25,6 +30,12 @@ import java.util.ResourceBundle;
|
||||
public class FlightSummaryController extends Controller {
|
||||
|
||||
private Dataset theDataSet = null;
|
||||
|
||||
@FXML
|
||||
private Button flightRawData;
|
||||
private Map map;
|
||||
@FXML
|
||||
private WebView mapView;
|
||||
private int currentPathId = 0;
|
||||
private int currentPathIndex = 0;
|
||||
|
||||
@@ -99,6 +110,16 @@ public class FlightSummaryController extends Controller {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
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());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package seng202.group9.Map;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.concurrent.Worker;
|
||||
import javafx.scene.web.WebEngine;
|
||||
import javafx.scene.web.WebView;
|
||||
import seng202.group9.Core.Position;
|
||||
import seng202.group9.Core.RoutePath;
|
||||
|
||||
/**
|
||||
* Created by fwy13 on 17/09/16.
|
||||
*/
|
||||
public class Map {
|
||||
|
||||
private WebEngine webEngine;
|
||||
private WebView webView;
|
||||
private boolean canLoad = false;
|
||||
|
||||
public Map(WebView webView, final RoutePath newRoute){
|
||||
this.webView = webView;
|
||||
webEngine = webView.getEngine();
|
||||
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() {
|
||||
webEngine.load(getClass().getClassLoader().getResource("map.html").toExternalForm());
|
||||
}
|
||||
|
||||
public void displayRoute(RoutePath newRoute) {
|
||||
String scriptToExecute = "displayRoute(" + newRoute.toJSONArray() + ");";
|
||||
webEngine.executeScript(scriptToExecute);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,9 +9,9 @@
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.shape.Rectangle?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
<?import javafx.scene.web.WebView?>
|
||||
|
||||
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.45" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.AirlineSummaryController">
|
||||
<children>
|
||||
@@ -83,7 +83,7 @@
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</padding>
|
||||
</Pane>
|
||||
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="200.0" stroke="BLACK" strokeType="INSIDE" width="252.0" />
|
||||
<WebView fx:id="mapView" prefHeight="200.0" prefWidth="252.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.shape.Rectangle?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
<?import javafx.scene.web.WebView?>
|
||||
|
||||
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.45" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.AirportSummaryController">
|
||||
<children>
|
||||
@@ -83,8 +83,10 @@
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</padding>
|
||||
<children>
|
||||
<WebView fx:id="mapView" prefHeight="200.0" prefWidth="254.0" />
|
||||
</children>
|
||||
</Pane>
|
||||
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="200.0" stroke="BLACK" strokeType="INSIDE" width="252.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
|
||||
@@ -73,8 +73,7 @@
|
||||
</Pane>
|
||||
<Pane prefHeight="934.0" prefWidth="474.0" GridPane.columnIndex="1" GridPane.rowIndex="1">
|
||||
<children>
|
||||
<WebView prefHeight="431.0" prefWidth="310.0" />
|
||||
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="#0d93e0" height="432.0" layoutX="5.0" layoutY="-1.0" smooth="false" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" width="305.0" />
|
||||
<WebView fx:id="mapView" prefHeight="431.0" prefWidth="310.0" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Google Map Demo</title>
|
||||
<meta name="viewport" content="initial-scale=1.0">
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
html, body {
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
#map {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
<script>
|
||||
var map;
|
||||
var marker1;
|
||||
var marker2;
|
||||
var path;
|
||||
|
||||
function initMap() {
|
||||
map = new google.maps.Map(document.getElementById('map'), {
|
||||
center: {lat: 39.144684, lng: -84.510079},
|
||||
zoom: 15
|
||||
});
|
||||
|
||||
new google.maps.Marker({
|
||||
position: {lat: 39.144684, lng: -84.510079},
|
||||
map: map,
|
||||
title: '\u0048\u0061\u0072\u0061\u006d\u0062\u0065'
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
// CLEAR EXISTING MARKERS
|
||||
if (marker1 !== undefined && marker2 !== undefined && path !== undefined) {
|
||||
marker1.setMap(null);
|
||||
marker2.setMap(null);
|
||||
path.setMap(null);
|
||||
}
|
||||
|
||||
if (flightPath.length < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
// CREATE MARKERS AT START AND FINISH
|
||||
marker1 = new google.maps.Marker({
|
||||
position: flightPath[0],
|
||||
map: map
|
||||
});
|
||||
|
||||
marker2 = new google.maps.Marker({
|
||||
position: flightPath[flightPath.length - 1],
|
||||
map: map
|
||||
});
|
||||
|
||||
// DRAW POLYLINE FOR ROUTE
|
||||
path = new google.maps.Polyline({
|
||||
path: flightPath,
|
||||
geodesic: true,
|
||||
strokeColor: '#FF0000',
|
||||
strokeOpacity: 1.0,
|
||||
strokeWeight: 2
|
||||
});
|
||||
|
||||
path.setMap(map);
|
||||
|
||||
repositionMap(flightPath);
|
||||
}
|
||||
|
||||
function repositionMap(flightPath) {
|
||||
var bounds = new google.maps.LatLngBounds();
|
||||
|
||||
for (var i = 0; i < flightPath.length; i++) {
|
||||
bounds.extend(flightPath[i]);
|
||||
}
|
||||
|
||||
map.fitBounds(bounds);
|
||||
}
|
||||
</script>
|
||||
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBnt2PJyKZsh-qrsTkbZwSGuUNWPromlLg&callback=initMap" defer></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,9 +9,9 @@
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.Pane?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.shape.Rectangle?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
<?import javafx.scene.web.WebView?>
|
||||
|
||||
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.45" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seng202.group9.GUI.RouteSummaryController">
|
||||
<children>
|
||||
@@ -83,8 +83,10 @@
|
||||
<padding>
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
||||
</padding>
|
||||
<children>
|
||||
<WebView fx:id="mapView" prefHeight="200.0" prefWidth="252.0" />
|
||||
</children>
|
||||
</Pane>
|
||||
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="200.0" stroke="BLACK" strokeType="INSIDE" width="252.0" />
|
||||
</children>
|
||||
</AnchorPane>
|
||||
</children>
|
||||
|
||||
Reference in New Issue
Block a user