|
|
|
|
@ -32,7 +32,7 @@ public class RaceData {
|
|
|
|
|
private OffsetDateTime creationTimeDate;
|
|
|
|
|
private OffsetDateTime raceStartTime;
|
|
|
|
|
private List<BoatInRace> participants;
|
|
|
|
|
private List<Leg> course;
|
|
|
|
|
private List<Marker> course;
|
|
|
|
|
private List<GPSCoordinate> courseLimit;
|
|
|
|
|
|
|
|
|
|
public RaceData(RaceDataSource dataSource) {
|
|
|
|
|
@ -42,7 +42,7 @@ public class RaceData {
|
|
|
|
|
creationTimeDate = OffsetDateTime.now();
|
|
|
|
|
raceStartTime = OffsetDateTime.now().plusMinutes(3);
|
|
|
|
|
participants = dataSource.getBoats();
|
|
|
|
|
course = dataSource.getLegs();
|
|
|
|
|
course = dataSource.getMarkers();
|
|
|
|
|
courseLimit = dataSource.getBoundary();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -55,29 +55,82 @@ public class RaceData {
|
|
|
|
|
|
|
|
|
|
// root elements
|
|
|
|
|
Document doc = docBuilder.newDocument();
|
|
|
|
|
Element rootElement = doc.createElement("Race");
|
|
|
|
|
doc.appendChild(rootElement);
|
|
|
|
|
|
|
|
|
|
// shorten way
|
|
|
|
|
// staff.setAttribute("id", "1");
|
|
|
|
|
Element raceElement = doc.createElement("Race");
|
|
|
|
|
doc.appendChild(raceElement);
|
|
|
|
|
|
|
|
|
|
Element raceIdElement = doc.createElement("RaceID");
|
|
|
|
|
raceIdElement.appendChild(doc.createTextNode(raceID));
|
|
|
|
|
rootElement.appendChild(raceIdElement);
|
|
|
|
|
raceElement.appendChild(raceIdElement);
|
|
|
|
|
|
|
|
|
|
Element raceTypeElement = doc.createElement("RaceType");
|
|
|
|
|
raceTypeElement.appendChild(doc.createTextNode(raceType));
|
|
|
|
|
rootElement.appendChild(raceTypeElement);
|
|
|
|
|
raceElement.appendChild(raceTypeElement);
|
|
|
|
|
|
|
|
|
|
Element creationTimeElement = doc.createElement("CreationTimeDate");
|
|
|
|
|
creationTimeElement.appendChild(doc.createTextNode(creationTimeDate.toString()));
|
|
|
|
|
rootElement.appendChild(creationTimeElement);
|
|
|
|
|
raceElement.appendChild(creationTimeElement);
|
|
|
|
|
|
|
|
|
|
Element startTimeElement = doc.createElement("RaceStartTime");
|
|
|
|
|
startTimeElement.setAttribute("Time", raceStartTime.toString());
|
|
|
|
|
startTimeElement.setAttribute("Postpone", "false");
|
|
|
|
|
rootElement.appendChild(startTimeElement);
|
|
|
|
|
raceElement.appendChild(startTimeElement);
|
|
|
|
|
|
|
|
|
|
//PARTICIPANTS
|
|
|
|
|
|
|
|
|
|
Element courseElement = doc.createElement("Course");
|
|
|
|
|
Element compoundMarkSeqElement = doc.createElement("CompoundMarkSequence");
|
|
|
|
|
|
|
|
|
|
int i = 1;
|
|
|
|
|
for (Marker marker : course) {
|
|
|
|
|
Element compoundMarkElement = doc.createElement("CompoundMark");
|
|
|
|
|
compoundMarkElement.setAttribute("CompoundMarkId", i + "");
|
|
|
|
|
compoundMarkElement.setAttribute("Name", marker.getName());
|
|
|
|
|
|
|
|
|
|
Element mark1 = doc.createElement("Mark");
|
|
|
|
|
mark1.setAttribute("TargetLat", marker.getMark1().getLatitude() + "");
|
|
|
|
|
mark1.setAttribute("TargetLng", marker.getMark1().getLongitude() + "");
|
|
|
|
|
|
|
|
|
|
compoundMarkElement.appendChild(mark1);
|
|
|
|
|
|
|
|
|
|
if (!(marker.getMark1().equals(marker.getMark2()))) {
|
|
|
|
|
Element mark2 = doc.createElement("Mark");
|
|
|
|
|
mark2.setAttribute("TargetLat", marker.getMark2().getLatitude() + "");
|
|
|
|
|
mark2.setAttribute("TargetLng", marker.getMark2().getLongitude() + "");
|
|
|
|
|
compoundMarkElement.appendChild(mark2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
courseElement.appendChild(compoundMarkElement);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Element cornerElement = doc.createElement("Corner");
|
|
|
|
|
cornerElement.setAttribute("SeqID", i + "");
|
|
|
|
|
cornerElement.setAttribute("CompoundMarkID", i + "");
|
|
|
|
|
|
|
|
|
|
compoundMarkSeqElement.appendChild(cornerElement);
|
|
|
|
|
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
raceElement.appendChild(compoundMarkSeqElement);
|
|
|
|
|
raceElement.appendChild(courseElement);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int j = 1;
|
|
|
|
|
|
|
|
|
|
Element courseLimitElement = doc.createElement("CourseLimit");
|
|
|
|
|
for (GPSCoordinate coordinate : courseLimit) {
|
|
|
|
|
Element limitElement = doc.createElement("Limit");
|
|
|
|
|
limitElement.setAttribute("SeqID", j + "");
|
|
|
|
|
|
|
|
|
|
limitElement.setAttribute("Lat", coordinate.getLatitude() + "");
|
|
|
|
|
limitElement.setAttribute("Lon", coordinate.getLongitude() + "");
|
|
|
|
|
|
|
|
|
|
courseLimitElement.appendChild(limitElement);
|
|
|
|
|
|
|
|
|
|
j++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
raceElement.appendChild(courseLimitElement);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// write the content into xml file
|
|
|
|
|
|