Re-enabled source id allocator check.
Re-enabled rotation of map at startup. Changed race.xml schema so that yacht elements aren't required inside the participants element. #story[1185]
This commit is contained in:
@@ -26,6 +26,7 @@ import javax.xml.validation.SchemaFactory;
|
||||
import javax.xml.validation.Validator;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringWriter;
|
||||
import java.math.BigInteger;
|
||||
import java.net.URL;
|
||||
@@ -64,33 +65,37 @@ public class RaceXMLCreator {
|
||||
|
||||
/**
|
||||
* Rotates the race in a specified direction.
|
||||
* @param s xml file name
|
||||
* @param s xml file name or contents.
|
||||
* @param fileType Whether s is a file name or contents.
|
||||
* @param degrees degrees to rotate
|
||||
* @return the new xml file as a string
|
||||
* @throws XMLReaderException if the xml is not readable
|
||||
* @throws InvalidRaceDataException if the race is invalid
|
||||
* @throws JAXBException if the Race class cannot be parsed into a xml.
|
||||
* @throws IOException if the schema file cannot be found
|
||||
* @throws SAXException error in schema file
|
||||
* @throws ParserConfigurationException error in parsing the schema file
|
||||
*/
|
||||
public static String alterRaceToWind(String s, double degrees) throws XMLReaderException, InvalidRaceDataException, JAXBException, IOException, SAXException, ParserConfigurationException {
|
||||
RaceXMLReader reader = new RaceXMLReader(s, XMLFileType.ResourcePath);
|
||||
public static String alterRaceToWind(String s, XMLFileType fileType, double degrees) throws XMLReaderException, InvalidRaceDataException {
|
||||
|
||||
XMLRace race = XMLUtilities.xmlToClass(
|
||||
RaceXMLCreator.class.getClassLoader().getResourceAsStream(s),
|
||||
RaceXMLCreator.class.getClassLoader().getResource("mock/mockXML/schema/raceSchema.xsd"),
|
||||
XMLRace.class);
|
||||
RaceXMLReader reader = new RaceXMLReader(s, fileType);
|
||||
|
||||
setRaceXMLAtCurrentTimeToNow(race);
|
||||
try {
|
||||
|
||||
double raceOriginalBearing = getLineAngle(getLeewardGate(reader).getMark1Position(), getWindwardGate(reader).getMark1Position());
|
||||
XMLRace race = XMLUtilities.xmlToClass(
|
||||
s,
|
||||
RaceXMLCreator.class.getClassLoader().getResource("mock/mockXML/schema/raceSchema.xsd"),
|
||||
XMLRace.class);
|
||||
|
||||
double degreesToRotate = degrees - raceOriginalBearing;
|
||||
setRaceXMLAtCurrentTimeToNow(race);
|
||||
|
||||
alterRaceRotation(race, degreesToRotate);
|
||||
double raceOriginalBearing = getLineAngle(getLeewardGate(reader).getMark1Position(), getWindwardGate(reader).getMark1Position());
|
||||
|
||||
return XMLUtilities.classToXML(race);
|
||||
double degreesToRotate = degrees - raceOriginalBearing;
|
||||
|
||||
alterRaceRotation(race, degreesToRotate);
|
||||
|
||||
return XMLUtilities.classToXML(race);
|
||||
|
||||
} catch (ParserConfigurationException | IOException | SAXException | JAXBException e) {
|
||||
throw new InvalidRaceDataException("Could not parse or marshall race data file.", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user