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.stage.Stage;
|
||||
import org.xml.sax.SAXException;
|
||||
import seng302.DataInput.RaceDataSource;
|
||||
import seng302.DataInput.RaceXMLReader;
|
||||
import seng302.DataInput.RegattaDataSource;
|
||||
import seng302.DataInput.RegattaXMLReader;
|
||||
import seng302.DataInput.*;
|
||||
import seng302.Model.Event;
|
||||
import seng302.Model.Polars;
|
||||
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
@@ -28,7 +26,8 @@ public class App extends Application {
|
||||
@Override
|
||||
public void start(Stage primaryStage) {
|
||||
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");
|
||||
Event raceEvent = new Event(raceData, regattaData);
|
||||
raceEvent.start();
|
||||
|
||||
@@ -5,10 +5,7 @@ import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import seng302.Model.Boat;
|
||||
import seng302.Model.GPSCoordinate;
|
||||
import seng302.Model.Leg;
|
||||
import seng302.Model.Marker;
|
||||
import seng302.Model.*;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.IOException;
|
||||
@@ -28,6 +25,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
||||
private GPSCoordinate mapTopLeft, mapBottomRight;
|
||||
private List<GPSCoordinate> boundary = new ArrayList<>();
|
||||
private List<Marker> markers = new ArrayList<>();
|
||||
private Polars boatPolars;
|
||||
|
||||
/**
|
||||
* Constractor for Race XML
|
||||
@@ -41,6 +39,19 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
||||
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
|
||||
*
|
||||
@@ -90,6 +101,7 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
||||
double velo = Double.parseDouble(getTextValueOfNode((Element) nBoats.item(i), "speed"));
|
||||
int sourceID = Integer.parseInt(getTextValueOfNode((Element) nBoats.item(i), "sourceID"));
|
||||
Boat boat = new Boat(name, velo, abbrev, sourceID);
|
||||
boat.setPolars(boatPolars);
|
||||
boat.setCurrentPosition(startPt1);
|
||||
if (legs.size() > 0) {
|
||||
boat.setCurrentLeg(legs.get(0));
|
||||
|
||||
Reference in New Issue
Block a user