mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-07 19:42:17 +00:00
removed GPS position again from xcelsius rankPerLeg service and added a placeholder
gpsPerRace service which does deliver the GPS coordinates; this latter service hasn't been aligned with the Xcelsius requirements yet and is merely a code sample for accessing the tracking information about positions.
This commit is contained in:
1 parent
79c0ec8bbd
commit
7ef80d5891
5 files changed
+162
-8
No files matched your search
@@ -46,7 +46,7 @@ the correct directory, if not already there:
|
||||
|
||||
Then launch the server:
|
||||
|
||||
- ./start
|
||||
- ./start 2>&1 | tee log
|
||||
|
||||
This should start an OSGi console with the latest version of the
|
||||
bundles deployed to ~trac/servers/<instance>/plugins.
|
||||
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
package com.sap.sailing.xcelsiusadapter;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.jdom.Document;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.Distance;
|
||||
import com.sap.sailing.domain.base.Event;
|
||||
import com.sap.sailing.domain.base.Leg;
|
||||
import com.sap.sailing.domain.base.RaceDefinition;
|
||||
import com.sap.sailing.domain.base.Speed;
|
||||
import com.sap.sailing.domain.base.SpeedWithBearing;
|
||||
import com.sap.sailing.domain.base.TimePoint;
|
||||
import com.sap.sailing.domain.tracking.GPSFixMoving;
|
||||
import com.sap.sailing.domain.tracking.GPSFixTrack;
|
||||
import com.sap.sailing.domain.tracking.TrackedLeg;
|
||||
import com.sap.sailing.domain.tracking.TrackedLegOfCompetitor;
|
||||
import com.sap.sailing.domain.tracking.TrackedRace;
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
|
||||
public class GPSPerRace extends Action {
|
||||
private final Set<String> competitorNameSet;
|
||||
|
||||
public GPSPerRace(HttpServletRequest req, HttpServletResponse res, RacingEventService service, int maxRows) {
|
||||
super(req, res, service, maxRows);
|
||||
String[] competitors = req.getParameterValues("competitor");
|
||||
if (competitors == null) {
|
||||
competitorNameSet = null;
|
||||
} else {
|
||||
competitorNameSet = new HashSet<String>();
|
||||
for (String competitorName : competitors) {
|
||||
competitorNameSet.add(competitorName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void perform() throws Exception {
|
||||
// Get data from request
|
||||
final Event event = getEvent();
|
||||
final RaceDefinition race = getRace(event);
|
||||
final TrackedRace trackedRace = getTrackedRace(event, race);
|
||||
final TimePoint time = getTimePoint(trackedRace);
|
||||
// Prepare document
|
||||
final Document table = getTable("data");
|
||||
// Get Legs data
|
||||
int i=0;
|
||||
NumberFormat numberFormat = new DecimalFormat("00");
|
||||
TrackedLeg previousLeg = null;
|
||||
for (final TrackedLeg trackedLeg : trackedRace.getTrackedLegs()) {
|
||||
final Leg leg = trackedLeg.getLeg();
|
||||
final String legId = numberFormat.format(++i);
|
||||
final String markName = leg.getTo().getName();
|
||||
final String upOrDownwinLeg = trackedLeg.isUpOrDownwindLeg(time) ? "U" : "D";
|
||||
LinkedHashMap<Competitor, Integer> ranks = trackedLeg.getRanks(time);
|
||||
// Get competitor data
|
||||
for (final Competitor competitor : ranks.keySet()) {
|
||||
if (competitorNameSet == null || competitorNameSet.contains(competitor.getName())) {
|
||||
// Get data
|
||||
final String competitorName = competitor.getName();
|
||||
final String nationality = competitor.getTeam().getNationality().getThreeLetterIOCAcronym();
|
||||
final String sailID = competitor.getBoat().getSailID();
|
||||
final int overallRank = trackedRace.getRank(competitor);
|
||||
TrackedLegOfCompetitor trackedLegOfCompetitor = trackedLeg.getTrackedLeg(competitor);
|
||||
final int legRank = trackedLegOfCompetitor.getRank(time);
|
||||
int posGL = 0;
|
||||
if (previousLeg != null) {
|
||||
posGL = legRank - previousLeg.getTrackedLeg(competitor).getRank(time);
|
||||
}
|
||||
final Double gapToLeader = trackedLegOfCompetitor.getGapToLeaderInSeconds(time);
|
||||
final double legTime = 1./1000.*trackedLegOfCompetitor.getTimeInMilliSeconds(time);
|
||||
final Speed avgSpeed = trackedLegOfCompetitor.getAverageSpeedOverGround(time);
|
||||
final Distance distanceSailed = trackedLegOfCompetitor.getDistanceTraveled(time);
|
||||
|
||||
// Write data
|
||||
addRow();
|
||||
addColumn(legId);
|
||||
addColumn(markName);
|
||||
addColumn(leg.getTo().getBuoys().iterator().next().getName());
|
||||
addColumn(upOrDownwinLeg);
|
||||
addColumn(competitorName);
|
||||
addColumn(sailID==null?"null":sailID);
|
||||
addColumn(nationality);
|
||||
addColumn("" + overallRank);
|
||||
addColumn("" + legRank);
|
||||
addColumn("" + posGL);
|
||||
addColumn("" + (gapToLeader==null ? "null" : gapToLeader));
|
||||
addColumn("" + legTime);
|
||||
addColumn("" + (avgSpeed == null ? "null" : avgSpeed.getKnots()));
|
||||
addColumn("" + (distanceSailed == null ? "null" : distanceSailed.getMeters()));
|
||||
|
||||
// position and tracking-related columns (see Kersten's mail of 2011-10-07T11:32:00CEST)
|
||||
GPSFixTrack<Competitor, GPSFixMoving> track = trackedRace.getTrack(competitor);
|
||||
GPSFixMoving fix = track.getFirstFixAtOrAfter(time);
|
||||
addColumn(""+(fix==null?"null":fix.getPosition().getLngDeg()));
|
||||
addColumn(""+(fix==null?"null":fix.getPosition().getLatDeg()));
|
||||
SpeedWithBearing speedOverGround = trackedLegOfCompetitor.getSpeedOverGround(time);
|
||||
addColumn(""+(speedOverGround==null?"null":speedOverGround.getKnots()));
|
||||
Double estimatedTimeToNextMarkInSeconds = trackedLegOfCompetitor.getEstimatedTimeToNextMarkInSeconds(time);
|
||||
addColumn(""+(estimatedTimeToNextMarkInSeconds==null?"null":estimatedTimeToNextMarkInSeconds));
|
||||
Speed velocityMadeGood = trackedLegOfCompetitor.getVelocityMadeGood(time);
|
||||
addColumn(""+(velocityMadeGood==null ? "null" : velocityMadeGood.getKnots()));
|
||||
}
|
||||
}
|
||||
previousLeg = trackedLeg;
|
||||
}
|
||||
say(table);
|
||||
}
|
||||
}
|
||||
-6
@@ -19,8 +19,6 @@ import com.sap.sailing.domain.base.RaceDefinition;
|
||||
import com.sap.sailing.domain.base.Speed;
|
||||
import com.sap.sailing.domain.base.SpeedWithBearing;
|
||||
import com.sap.sailing.domain.base.TimePoint;
|
||||
import com.sap.sailing.domain.tracking.GPSFixMoving;
|
||||
import com.sap.sailing.domain.tracking.GPSFixTrack;
|
||||
import com.sap.sailing.domain.tracking.TrackedLeg;
|
||||
import com.sap.sailing.domain.tracking.TrackedLegOfCompetitor;
|
||||
import com.sap.sailing.domain.tracking.TrackedRace;
|
||||
@@ -97,10 +95,6 @@ public class RankPerLeg extends Action {
|
||||
addColumn("" + (distanceSailed == null ? "null" : distanceSailed.getMeters()));
|
||||
|
||||
// position and tracking-related columns (see Kersten's mail of 2011-10-07T11:32:00CEST)
|
||||
GPSFixTrack<Competitor, GPSFixMoving> track = trackedRace.getTrack(competitor);
|
||||
GPSFixMoving fix = track.getFirstFixAtOrAfter(time);
|
||||
addColumn(""+(fix==null?"null":fix.getPosition().getLngDeg()));
|
||||
addColumn(""+(fix==null?"null":fix.getPosition().getLatDeg()));
|
||||
SpeedWithBearing speedOverGround = trackedLegOfCompetitor.getSpeedOverGround(time);
|
||||
addColumn(""+(speedOverGround==null?"null":speedOverGround.getKnots()));
|
||||
Double estimatedTimeToNextMarkInSeconds = trackedLegOfCompetitor.getEstimatedTimeToNextMarkInSeconds(time);
|
||||
|
||||
+4
@@ -31,6 +31,10 @@ public class XcelsiusApp extends Servlet {
|
||||
final RankPerLeg a = new RankPerLeg(req, res, getService(), maxRows);
|
||||
a.perform();
|
||||
return;
|
||||
} else if ("gpsPerRace".equals(action)) {
|
||||
final GPSPerRace a = new GPSPerRace(req, res, getService(), maxRows);
|
||||
a.perform();
|
||||
return;
|
||||
} else if ("listEvents".equals(action)) {
|
||||
final ListEvents a = new ListEvents(req, res, getService(), maxRows);
|
||||
a.perform();
|
||||
|
||||
+41
-1
@@ -6,7 +6,7 @@
|
||||
<directoryPermissions>775</directoryPermissions>
|
||||
</server>
|
||||
</servers>
|
||||
<!-- -->
|
||||
<!--
|
||||
<proxies>
|
||||
<proxy>
|
||||
<active>true</active>
|
||||
@@ -16,7 +16,47 @@
|
||||
<nonProxyHosts>localhost|*.sap.corp</nonProxyHosts>
|
||||
</proxy>
|
||||
</proxies>
|
||||
-->
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>snapshot.build</id>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>build.snapshots</id>
|
||||
<url>http://nexus.wdf.sap.corp:8081/nexus/content/groups/build.snapshots/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<url>http://repo1.maven.org/maven2</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<layout>p2</layout>
|
||||
<id>eclipse</id>
|
||||
<url>http://download.eclipse.org/releases/indigo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>build.snapshots</id>
|
||||
<url>http://nexus.wdf.sap.corp:8081/nexus/content/groups/build.snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<!-- definition of mirrors (by default the public repository of the Nexus server) -->
|
||||
<!-- -->
|
||||
<mirrors>
|
||||
<mirror>
|
||||
<id>leandi.nexus.mirror</id>
|
||||
<url>http://nexus.wdf.sap.corp:8081/nexus/content/groups/build.snapshots/</url>
|
||||
<mirrorOf>*,!build.snapshots,!build.milestones,!sonar</mirrorOf>
|
||||
</mirror>
|
||||
</mirrors>
|
||||
<!-- -->
|
||||
|
||||
|
||||
</settings>
|
||||
|
||||
|
||||
Reference in new issue
Block a user