Added some doc strings
- Added doc strings to RaceXML - Added a few minor changes to bermuda_AC35.xml - Changes to the RaceXMLReader Unit Test
This commit is contained in:
@@ -24,11 +24,25 @@ public class RaceXMLReader extends XMLReader {
|
||||
private ArrayList<GPSCoordinate> boundary = new ArrayList<>();
|
||||
private static double COORDINATEPADDING = 0.0005;
|
||||
|
||||
|
||||
/**
|
||||
* Constractor for Race XML
|
||||
* @param filePath path of the file
|
||||
* @throws IOException
|
||||
* @throws SAXException
|
||||
* @throws ParserConfigurationException
|
||||
*/
|
||||
public RaceXMLReader(String filePath) throws IOException, SAXException, ParserConfigurationException {
|
||||
this(filePath, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* COnstructor for Race XML
|
||||
* @param filePath file path to read
|
||||
* @param read whether or not to read and store the files straight away.
|
||||
* @throws IOException
|
||||
* @throws SAXException
|
||||
* @throws ParserConfigurationException
|
||||
*/
|
||||
public RaceXMLReader(String filePath, boolean read) throws IOException, SAXException, ParserConfigurationException {
|
||||
super(filePath);
|
||||
if (read) {
|
||||
@@ -36,12 +50,18 @@ public class RaceXMLReader extends XMLReader {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the files
|
||||
*/
|
||||
private void read() {
|
||||
readCourse();
|
||||
readLegs();
|
||||
readBoats();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read all the boats in the XML file
|
||||
*/
|
||||
public void readBoats() {
|
||||
//get all boats
|
||||
NodeList nBoats = doc.getElementsByTagName("boat");
|
||||
@@ -59,6 +79,9 @@ public class RaceXMLReader extends XMLReader {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read all the legs in the XML file
|
||||
*/
|
||||
public void readLegs() {
|
||||
//get all legs
|
||||
NodeList nLegs = doc.getElementsByTagName("leg");
|
||||
@@ -73,6 +96,9 @@ public class RaceXMLReader extends XMLReader {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read courses in XML file
|
||||
*/
|
||||
public void readCourse() {
|
||||
NodeList nCourse = doc.getElementsByTagName("course");
|
||||
|
||||
@@ -140,20 +166,43 @@ public class RaceXMLReader extends XMLReader {
|
||||
finishPt2 = getCoordinates(nMarks, 4, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a marker from the XML file
|
||||
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
|
||||
* @return
|
||||
*/
|
||||
private Marker getMarker(NodeList start) {
|
||||
return getMarker(start, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a marker from the XML file
|
||||
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
|
||||
* @param startIndex index in the node that has the coordinate tag
|
||||
* @return
|
||||
*/
|
||||
private Marker getMarker(NodeList start, int startIndex) {
|
||||
return getMarker(start, startIndex, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a marker from the XML file
|
||||
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
|
||||
* @param startIndex index in the node that has the coordinate tag
|
||||
* @param nodeIndex coordinate index
|
||||
* @return
|
||||
*/
|
||||
private Marker getMarker(NodeList start, int startIndex, int nodeIndex) {
|
||||
NodeList nodeList = ((Element) start.item(startIndex)).getElementsByTagName("marker");
|
||||
Element marker = (Element) nodeList.item(nodeIndex);
|
||||
return getMarker(marker);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a changes a marker to GPS coordinates into a marker
|
||||
* @param markerNode marker to turn into coordinates
|
||||
* @return
|
||||
*/
|
||||
private Marker getMarker(Element markerNode) {
|
||||
|
||||
NodeList nCoordinates = markerNode.getElementsByTagName("coordinate");
|
||||
@@ -169,14 +218,32 @@ public class RaceXMLReader extends XMLReader {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a coordinates from the XML file
|
||||
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
|
||||
* @return
|
||||
*/
|
||||
private GPSCoordinate getCoordinates(NodeList start) {
|
||||
return getCoordinates(start, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a coordinates from the XML file
|
||||
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
|
||||
* @param startIndex the index the tag containing the coordinate should be in
|
||||
* @return
|
||||
*/
|
||||
private GPSCoordinate getCoordinates(NodeList start, int startIndex) {
|
||||
return getCoordinates(start, startIndex, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets a coordinates from the XML file
|
||||
* @param start base nodelist this should be the tag that contains <coordinate></coordinate>
|
||||
* @param startIndex the index the tag containing the coordinate should be in
|
||||
* @param nodeIndex The coordinate index
|
||||
* @return
|
||||
*/
|
||||
private GPSCoordinate getCoordinates(NodeList start, int startIndex, int nodeIndex) {
|
||||
NodeList nodeList = ((Element) start.item(startIndex)).getElementsByTagName("coordinate");
|
||||
Element coord = (Element) nodeList.item(nodeIndex);
|
||||
|
||||
@@ -173,16 +173,16 @@
|
||||
<longitude>-64.837168</longitude>
|
||||
</coordinate>
|
||||
<coordinate>
|
||||
<latitude>32.317403</latitude>
|
||||
<longitude>-64.838627</longitude>
|
||||
<latitude>32.317379</latitude>
|
||||
<longitude>-64.839291</longitude>
|
||||
</coordinate>
|
||||
<coordinate>
|
||||
<latitude>32.317911</latitude>
|
||||
<longitude>-64.836996</longitude>
|
||||
</coordinate>
|
||||
<coordinate>
|
||||
<latitude>32.317548</latitude>
|
||||
<longitude>-64.835022</longitude>
|
||||
<latitude>32.317257</latitude>
|
||||
<longitude>-64.836260</longitude>
|
||||
</coordinate>
|
||||
<coordinate>
|
||||
<latitude>32.304273</latitude>
|
||||
|
||||
Reference in New Issue
Block a user