updated app class to read the polar csv and pass it off to its parser
#story[900]
This commit is contained in:
@@ -4,11 +4,9 @@ package seng302;
|
|||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
import seng302.DataInput.RaceDataSource;
|
import seng302.DataInput.*;
|
||||||
import seng302.DataInput.RaceXMLReader;
|
|
||||||
import seng302.DataInput.RegattaDataSource;
|
|
||||||
import seng302.DataInput.RegattaXMLReader;
|
|
||||||
import seng302.Model.Event;
|
import seng302.Model.Event;
|
||||||
|
import seng302.Model.Polars;
|
||||||
|
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
@@ -28,7 +26,8 @@ public class App extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
try {
|
try {
|
||||||
RaceDataSource raceData = new RaceXMLReader("raceXML/bermuda_AC35.xml");
|
Polars boatPolars = PolarParser.parse("polars/acc_polars.csv");
|
||||||
|
RaceDataSource raceData = new RaceXMLReader("raceXML/bermuda_AC35.xml", boatPolars);
|
||||||
RegattaDataSource regattaData = new RegattaXMLReader("mockXML/regattaTest.xml");
|
RegattaDataSource regattaData = new RegattaXMLReader("mockXML/regattaTest.xml");
|
||||||
Event raceEvent = new Event(raceData, regattaData);
|
Event raceEvent = new Event(raceData, regattaData);
|
||||||
raceEvent.start();
|
raceEvent.start();
|
||||||
|
|||||||
@@ -5,10 +5,7 @@ import org.w3c.dom.Element;
|
|||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
import seng302.Model.Boat;
|
import seng302.Model.*;
|
||||||
import seng302.Model.GPSCoordinate;
|
|
||||||
import seng302.Model.Leg;
|
|
||||||
import seng302.Model.Marker;
|
|
||||||
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -28,6 +25,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
private GPSCoordinate mapTopLeft, mapBottomRight;
|
private GPSCoordinate mapTopLeft, mapBottomRight;
|
||||||
private List<GPSCoordinate> boundary = new ArrayList<>();
|
private List<GPSCoordinate> boundary = new ArrayList<>();
|
||||||
private List<Marker> markers = new ArrayList<>();
|
private List<Marker> markers = new ArrayList<>();
|
||||||
|
private Polars boatPolars;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constractor for Race XML
|
* Constractor for Race XML
|
||||||
@@ -41,6 +39,19 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
this(filePath, true);
|
this(filePath, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constractor for Race XML
|
||||||
|
*
|
||||||
|
* @param filePath path of the file
|
||||||
|
* @throws IOException error
|
||||||
|
* @throws SAXException error
|
||||||
|
* @throws ParserConfigurationException error
|
||||||
|
*/
|
||||||
|
public RaceXMLReader(String filePath, Polars boatPolars) throws IOException, SAXException, ParserConfigurationException {
|
||||||
|
this(filePath, true);
|
||||||
|
this.boatPolars = boatPolars;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* COnstructor for Race XML
|
* COnstructor for Race XML
|
||||||
*
|
*
|
||||||
@@ -90,6 +101,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
|||||||
double velo = Double.parseDouble(getTextValueOfNode((Element) nBoats.item(i), "speed"));
|
double velo = Double.parseDouble(getTextValueOfNode((Element) nBoats.item(i), "speed"));
|
||||||
int sourceID = Integer.parseInt(getTextValueOfNode((Element) nBoats.item(i), "sourceID"));
|
int sourceID = Integer.parseInt(getTextValueOfNode((Element) nBoats.item(i), "sourceID"));
|
||||||
Boat boat = new Boat(name, velo, abbrev, sourceID);
|
Boat boat = new Boat(name, velo, abbrev, sourceID);
|
||||||
|
boat.setPolars(boatPolars);
|
||||||
boat.setCurrentPosition(startPt1);
|
boat.setCurrentPosition(startPt1);
|
||||||
if (legs.size() > 0) {
|
if (legs.size() > 0) {
|
||||||
boat.setCurrentLeg(legs.get(0));
|
boat.setCurrentLeg(legs.get(0));
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
Tws,Twa0,Bsp0,Twa1,Bsp1,UpTwa,UpBsp,Twa2,Bsp2,Twa3,Bsp3,Twa4,Bsp4,Twa5,Bsp5,Twa6,Bsp6,DnTwa,DnBsp,Twa7,Bsp7
|
|
||||||
4,0,0,30,4,45,8,60,9,75,10,90,10,115,10,145,10,155,10,175,4
|
|
||||||
8,0,0,30,7,43,10,60,11,75,11,90,11,115,12,145,12,153,12,175,10
|
|
||||||
12,0,0,30,11,43,14.4,60,16,75,20,90,23,115,24,145,23,153,21.6,175,14
|
|
||||||
16,0,0,30,12,42,19.2,60,25,75,27,90,31,115,32,145,30,153,28.8,175,20
|
|
||||||
20,0,0,30,13,41,24,60,29,75,37,90,39,115,40,145,38,153,36,175,24
|
|
||||||
25,0,0,30,15,40,30,60,38,75,44,90,49,115,50,145,49,151,47,175,30
|
|
||||||
30,0,0,30,15,42,30,60,37,75,42,90,48,115,49,145,48,150,46,175,32
|
|
||||||
|
Reference in New Issue
Block a user