Removed some unneccessary code and comments from PolarParser.parse(...).
Fixed a bug where the polar parser would attempt to insert (wind speed, windspeed, windangle) instead of (windspeed, windangle, boatspeed). Removed some unused constructors from RaceXMLReader, and fixed a bug where it wouldn't actually use the polar table correctly. Boat's constructor now expects a Polars table. Added some comments to the Polars class, and specified the HashMap's template parameters Added PolarsTest - which needs to be implemented properly when the VMG calculations have been added. #story[900]
This commit is contained in:
@@ -6,6 +6,7 @@ import org.junit.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
import seng302.DataInput.RaceDataSource;
|
||||
import seng302.DataInput.RaceXMLReader;
|
||||
import seng302.Model.Polars;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.IOException;
|
||||
@@ -33,7 +34,7 @@ public class BoatDataTest {
|
||||
@Before
|
||||
public void initReader() {
|
||||
try {
|
||||
raceDataSource = new RaceXMLReader("raceXML/bermuda_AC35.xml");
|
||||
raceDataSource = new RaceXMLReader("raceXML/bermuda_AC35.xml", new Polars());
|
||||
BoatData boatData = new BoatData(raceDataSource.getBoats());
|
||||
result = boatData.createXML();
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.junit.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
import seng302.DataInput.RaceDataSource;
|
||||
import seng302.DataInput.RaceXMLReader;
|
||||
import seng302.Model.Polars;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.IOException;
|
||||
@@ -27,7 +28,7 @@ public class RaceDataTest {
|
||||
@Before
|
||||
public void initReader() {
|
||||
try {
|
||||
raceDataSource = new RaceXMLReader("raceXML/bermuda_AC35.xml");
|
||||
raceDataSource = new RaceXMLReader("raceXML/bermuda_AC35.xml", new Polars());
|
||||
RaceData raceData = new RaceData(raceDataSource);
|
||||
result = raceData.createXML();
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package seng302.DataInput;
|
||||
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import seng302.Exceptions.InvalidPolarFileException;
|
||||
import seng302.Model.Polars;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -17,10 +20,19 @@ public class PolarParserTest {
|
||||
*/
|
||||
public void testParse() throws Exception {
|
||||
|
||||
try {
|
||||
//Parse data file.
|
||||
Polars polars = PolarParser.parse("polars/acc_polars.csv");
|
||||
|
||||
//Polars = PolarParser.parse("polars/acc_polars.csv");
|
||||
|
||||
//If the parse function didn't through, it worked.
|
||||
assertTrue(true);
|
||||
}
|
||||
catch (InvalidPolarFileException e) {
|
||||
assertTrue(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public class BoatTest {
|
||||
|
||||
|
||||
private GPSCoordinate ORIGIN_COORDS = new GPSCoordinate(0, 0);
|
||||
private Boat TEST_BOAT = new Boat("Test", 1, "tt", 1);
|
||||
private Boat TEST_BOAT = new Boat("Test", 1, "tt", 1, new Polars());
|
||||
|
||||
@Test
|
||||
public void calculateDueNorthAzimuthReturns0() {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package seng302.Model;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
import seng302.DataInput.PolarParser;
|
||||
import seng302.Exceptions.InvalidPolarFileException;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
/**
|
||||
* Created by f123 on 10-May-17.
|
||||
*/
|
||||
public class PolarsTest {
|
||||
|
||||
@Test
|
||||
/**
|
||||
* Tests if we can parse a polar data file (stored in a string), create a polar table, and calculate VMG for a variety of values.
|
||||
*/
|
||||
public void testParseAndVMG() throws Exception {
|
||||
|
||||
//Read data.
|
||||
Polars polars;
|
||||
try {
|
||||
//Parse data file.
|
||||
polars = PolarParser.parse("polars/acc_polars.csv");
|
||||
}
|
||||
catch (InvalidPolarFileException e) {
|
||||
assertTrue(false);
|
||||
}
|
||||
|
||||
//Test 1.
|
||||
//TODO make these tests actually do something when the calculateVMG function is added.
|
||||
double windAngle1 = 31.5;
|
||||
double destAngle1 = 65.32;
|
||||
double windSpeed1 = 15;//knots
|
||||
//double vmgAngle1 = TODO;
|
||||
//double vmgSpeed1 = TODO;
|
||||
|
||||
//VMG calcVMG1 = Polars.calculateVMG(windAngle1, destAngle1, windSpeed1);
|
||||
//double calcVMGAngle1 = calcVMG1.getKey();
|
||||
//double calcVMGSpeed1 = calcVMG1.getValue();
|
||||
|
||||
//assertEquals(vmgAngle1, calcVMGAngle1, 0.1);
|
||||
//assertEquals(vmgSpeed1, calcVMGSpeed1, 0.1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public class RaceXMLTest {
|
||||
@Test
|
||||
public void canFindFile() {
|
||||
try {
|
||||
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
|
||||
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", new Polars());
|
||||
} catch (Exception e) {
|
||||
fail("Cannot find raceXML/bermuda_AC35.xml in the resources folder");
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class RaceXMLTest {
|
||||
@Test
|
||||
public void canReadBoats() {
|
||||
try {
|
||||
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
|
||||
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", new Polars());
|
||||
raceXMLReader.readBoats();
|
||||
List<Boat> boats = raceXMLReader.getBoats();
|
||||
assertTrue(boats.size() == 6);
|
||||
@@ -62,7 +62,7 @@ public class RaceXMLTest {
|
||||
@Test
|
||||
public void canReadLegs() {
|
||||
try {
|
||||
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
|
||||
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", new Polars());
|
||||
raceXMLReader.readLegs();
|
||||
assertTrue(raceXMLReader.getLegs().size() == 5);
|
||||
} catch (Exception e) {
|
||||
@@ -73,7 +73,7 @@ public class RaceXMLTest {
|
||||
@Test
|
||||
public void canReadCourse() {
|
||||
try {
|
||||
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
|
||||
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", new Polars());
|
||||
raceXMLReader.readCourse();
|
||||
assertTrue(raceXMLReader.getMapTopLeft() != null);
|
||||
assertTrue(raceXMLReader.getMapBottomRight() != null);
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
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