mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-04 11:23:50 +00:00
Merge branch 'spectator' into gwt
This commit is contained in:
commit
1a7e50646d
13 files changed
+86
-55
No files matched your search
+1
-1
@@ -50,7 +50,7 @@ public abstract class AbstractBearing implements Bearing {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) (1023 ^ Double.doubleToLongBits(getDegrees()));
|
||||
return 1023 ^ (int) getDegrees();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public abstract class AbstractSpeedImpl implements Speed {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return (int) (31 * Double.doubleToLongBits(getMetersPerSecond()));
|
||||
return 31 * (int) getMetersPerSecond();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-3
@@ -20,7 +20,7 @@ public class PlacemarkImpl implements Placemark {
|
||||
private SerializablePosition position;
|
||||
private long population;
|
||||
|
||||
public PlacemarkImpl() {}
|
||||
PlacemarkImpl() {}
|
||||
|
||||
/**
|
||||
* Creates a new Placemark with the given parameters as attributes.
|
||||
@@ -73,11 +73,12 @@ public class PlacemarkImpl implements Placemark {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder b = new StringBuilder(Placemark.class.getSimpleName() + "[");
|
||||
StringBuilder b = new StringBuilder();
|
||||
|
||||
b.append(name + ", ");
|
||||
b.append(countryCode + ", ");
|
||||
b.append(position.toString() + ", ");
|
||||
b.append(population + "]");
|
||||
b.append(population);
|
||||
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
+22
-18
@@ -1,38 +1,42 @@
|
||||
package com.sap.sailing.domain.common.impl;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.common.Placemark;
|
||||
import com.sap.sailing.domain.common.RacePlaceOrder;
|
||||
|
||||
public class RacePlaceOrderImpl implements RacePlaceOrder {
|
||||
public class RacePlaceOrderImpl implements RacePlaceOrder, Serializable {
|
||||
private static final long serialVersionUID = 7590835541329816755L;
|
||||
|
||||
private Iterable<Placemark> places;
|
||||
private List<Placemark> places;
|
||||
|
||||
RacePlaceOrderImpl() {}
|
||||
|
||||
public RacePlaceOrderImpl(Iterable<Placemark> places) {
|
||||
public RacePlaceOrderImpl(List<Placemark> places) {
|
||||
this.places = places;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Placemark> getPlaces() {
|
||||
return places;
|
||||
return Collections.unmodifiableCollection(places);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder b = new StringBuilder();
|
||||
boolean first = true;
|
||||
for (Placemark place : places) {
|
||||
if (first) {
|
||||
b.append(place.getCountryCode() + ", " + place.getName());
|
||||
first = false;
|
||||
} else {
|
||||
b.append(" -> " + place.getCountryCode() + ", " + place.getName());
|
||||
}
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
// @Override
|
||||
// public String toString() {
|
||||
// StringBuilder b = new StringBuilder();
|
||||
// boolean first = true;
|
||||
// for (Placemark place : places) {
|
||||
// if (first) {
|
||||
// b.append(place.getCountryCode() + ", " + place.getName());
|
||||
// first = false;
|
||||
// } else {
|
||||
// b.append(" -> " + place.getCountryCode() + ", " + place.getName());
|
||||
// }
|
||||
// }
|
||||
// return b.toString();
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
+12
-9
@@ -9,10 +9,9 @@ public class SerializablePositionImpl implements SerializablePosition {
|
||||
private double latDeg;
|
||||
private double lngDeg;
|
||||
|
||||
public SerializablePositionImpl() {}
|
||||
SerializablePositionImpl() {}
|
||||
|
||||
public SerializablePositionImpl(double latDeg, double lngDeg) {
|
||||
super();
|
||||
this.latDeg = latDeg;
|
||||
this.lngDeg = lngDeg;
|
||||
}
|
||||
@@ -21,15 +20,19 @@ public class SerializablePositionImpl implements SerializablePosition {
|
||||
public Position getPosition() {
|
||||
return new DegreePosition(latDeg, lngDeg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "(" + latDeg + ", " + lngDeg + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(latDeg);
|
||||
int result = 1;
|
||||
long temp = (int) latDeg;
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(lngDeg);
|
||||
temp = (int) latDeg;
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
@@ -42,10 +45,10 @@ public class SerializablePositionImpl implements SerializablePosition {
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
SerializablePositionImpl other = (SerializablePositionImpl) obj;
|
||||
if (Double.doubleToLongBits(latDeg) != Double.doubleToLongBits(other.latDeg))
|
||||
SerializablePositionImpl other = (SerializablePositionImpl) obj;
|
||||
if (!new Double(latDeg).equals(other.latDeg))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(lngDeg) != Double.doubleToLongBits(other.lngDeg))
|
||||
if (!new Double(lngDeg).equals(other.lngDeg))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
+20
-16
@@ -38,10 +38,10 @@ import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.RacePlaceOrder;
|
||||
import com.sap.sailing.domain.common.Tack;
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.WindSource;
|
||||
import com.sap.sailing.domain.common.impl.RacePlaceOrderImpl;
|
||||
import com.sap.sailing.domain.common.impl.Util;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.domain.common.WindSource;
|
||||
import com.sap.sailing.domain.tracking.GPSFix;
|
||||
import com.sap.sailing.domain.tracking.GPSFixMoving;
|
||||
import com.sap.sailing.domain.tracking.GPSFixTrack;
|
||||
@@ -959,6 +959,7 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RacePlaceOrder getPlaceOrder() {
|
||||
RacePlaceOrder order = null;
|
||||
Placemark startBest = null;
|
||||
@@ -988,25 +989,28 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
//Get finish position
|
||||
Waypoint finish = getRace().getCourse().getLastWaypoint();
|
||||
Iterable<MarkPassing> finishPassings = getMarkPassingsInOrder(finish);
|
||||
Iterator<MarkPassing> finishPassingsIterator = finishPassings.iterator();
|
||||
MarkPassing finishPassing = null;
|
||||
while (finishPassings.iterator().hasNext()) {
|
||||
finishPassing = (MarkPassing) finishPassings.iterator().next();
|
||||
while (finishPassingsIterator.hasNext()) {
|
||||
finishPassing = (MarkPassing) finishPassingsIterator.next();
|
||||
}
|
||||
Position finishPosition = getApproximatePosition(finish, finishPassing.getTimePoint());
|
||||
|
||||
try {
|
||||
//Get distance to nearest placemark and calculate the search radius
|
||||
Placemark finishNearest = ReverseGeocoder.INSTANCE.getPlacemarkNearest(finishPosition);
|
||||
Distance finishNearestDistance = finishNearest.distanceFrom(finishPosition);
|
||||
double finishRadius = finishNearestDistance.getKilometers() * GEONAMES_RADIUS_CACLCULATION_FACTOR;
|
||||
|
||||
//Get the estimated best finish place
|
||||
finishBest = ReverseGeocoder.INSTANCE.getPlacemarkLast(finishPosition, finishRadius,
|
||||
new Placemark.ByPopulationDistanceRatio(finishPosition));
|
||||
} catch (IOException e) {
|
||||
logger.throwing(TrackedRaceImpl.class.getName(), "getPlaceOrder()", e);
|
||||
} catch (ParseException e) {
|
||||
logger.throwing(TrackedRaceImpl.class.getName(), "getPlaceOrder()", e);
|
||||
if (startPosition.getDistance(finishPosition).getKilometers() > ReverseGeocoder.POSITION_CACHE_DISTANCE_LIMIT_IN_KM) {
|
||||
try {
|
||||
// Get distance to nearest placemark and calculate the search radius
|
||||
Placemark finishNearest = ReverseGeocoder.INSTANCE.getPlacemarkNearest(finishPosition);
|
||||
Distance finishNearestDistance = finishNearest.distanceFrom(finishPosition);
|
||||
double finishRadius = finishNearestDistance.getKilometers() * GEONAMES_RADIUS_CACLCULATION_FACTOR;
|
||||
|
||||
// Get the estimated best finish place
|
||||
finishBest = ReverseGeocoder.INSTANCE.getPlacemarkLast(finishPosition, finishRadius,
|
||||
new Placemark.ByPopulationDistanceRatio(finishPosition));
|
||||
} catch (IOException e) {
|
||||
logger.throwing(TrackedRaceImpl.class.getName(), "getPlaceOrder()", e);
|
||||
} catch (ParseException e) {
|
||||
logger.throwing(TrackedRaceImpl.class.getName(), "getPlaceOrder()", e);
|
||||
}
|
||||
}
|
||||
|
||||
if (startBest != null) {
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.sap.sailing.geocoding.impl.ReverseGeocoderImpl;
|
||||
public interface ReverseGeocoder {
|
||||
final ReverseGeocoder INSTANCE = new ReverseGeocoderImpl();
|
||||
final String GEONAMES_USER = "sailtracking";
|
||||
final double POSITION_CACHE_DISTANCE_LIMIT_IN_KM = 5.0;
|
||||
|
||||
/**
|
||||
* Returns the nearest {@link Placemark} towards the given {@link Position}.
|
||||
|
||||
+3
-3
@@ -34,7 +34,7 @@ public class ReverseGeocoderImpl implements ReverseGeocoder {
|
||||
* The first number is the distance in kilometers and the second number is a needed calculation factor and mustn't
|
||||
* be changed! To change the distance just change the first number!
|
||||
*/
|
||||
private final double POSITION_CACHE_DISTANCE_LIMIT = 5.0 * 0.00899928005759539236861051115911;
|
||||
private final double POSITION_CACHE_DISTANCE_LIMIT = ReverseGeocoder.POSITION_CACHE_DISTANCE_LIMIT_IN_KM * 0.00899928005759539236861051115911;
|
||||
private final int XKM_RADIUS = 5;
|
||||
private final int ROWS_PER_XKM_RADIUS = 15;
|
||||
|
||||
@@ -190,8 +190,8 @@ public class ReverseGeocoderImpl implements ReverseGeocoder {
|
||||
* The results of the search
|
||||
*/
|
||||
private void cachePlacemarks(Position position, Double radius, List<Placemark> placemarks) {
|
||||
Collections.sort(placemarks, new Placemark.ByDistance(position));
|
||||
cache.put(position, new Triple<Position, Double, List<Placemark>>(position, radius, placemarks));
|
||||
// Collections.sort(placemarks, new Placemark.ByDistance(position));
|
||||
// cache.put(position, new Triple<Position, Double, List<Placemark>>(position, radius, placemarks));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#Fri Jan 06 00:20:10 CET 2012
|
||||
#Mon Jan 16 18:21:00 CET 2012
|
||||
eclipse.preferences.version=1
|
||||
entryPointModules=
|
||||
filesCopiedToWebInfLib=gwt-servlet.jar
|
||||
gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBWy13YXIgLiAtbG9jYWxXb3JrZXJzIDNdXT48L2V4dHJhLWFyZ3M+PHZtLWFyZ3M+PCFbQ0RBVEFbLVhteDUxMm1dXT48L3ZtLWFyZ3M+PGVudHJ5LXBvaW50LW1vZHVsZT5jb20uc2FwLnNhaWxpbmcuZ3d0LnVpLkFkbWluQ29uc29sZTwvZW50cnktcG9pbnQtbW9kdWxlPjxlbnRyeS1wb2ludC1tb2R1bGU+Y29tLnNhcC5zYWlsaW5nLmd3dC51aS5MZWFkZXJib2FyZDwvZW50cnktcG9pbnQtbW9kdWxlPjxlbnRyeS1wb2ludC1tb2R1bGU+Y29tLnNhcC5zYWlsaW5nLmd3dC51aS5MZWFkZXJib2FyZEVkaXRpbmc8L2VudHJ5LXBvaW50LW1vZHVsZT48ZW50cnktcG9pbnQtbW9kdWxlPmNvbS5zYXAuc2FpbGluZy5nd3QudWkuVXNlck1hbmFnZW1lbnQ8L2VudHJ5LXBvaW50LW1vZHVsZT48L2d3dC1jb21waWxlLXNldHRpbmdzPg\=\=
|
||||
gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBWy13YXIgLiAtbG9jYWxXb3JrZXJzIDNdXT48L2V4dHJhLWFyZ3M+PHZtLWFyZ3M+PCFbQ0RBVEFbLVhteDUxMm1dXT48L3ZtLWFyZ3M+PGVudHJ5LXBvaW50LW1vZHVsZT5jb20uc2FwLnNhaWxpbmcuZ3d0LnVpLkFkbWluQ29uc29sZTwvZW50cnktcG9pbnQtbW9kdWxlPjxlbnRyeS1wb2ludC1tb2R1bGU+Y29tLnNhcC5zYWlsaW5nLmd3dC51aS5MZWFkZXJib2FyZDwvZW50cnktcG9pbnQtbW9kdWxlPjxlbnRyeS1wb2ludC1tb2R1bGU+Y29tLnNhcC5zYWlsaW5nLmd3dC51aS5MZWFkZXJib2FyZEVkaXRpbmc8L2VudHJ5LXBvaW50LW1vZHVsZT48ZW50cnktcG9pbnQtbW9kdWxlPmNvbS5zYXAuc2FpbGluZy5nd3QudWkuVXNlck1hbmFnZW1lbnQ8L2VudHJ5LXBvaW50LW1vZHVsZT48ZW50cnktcG9pbnQtbW9kdWxlPmNvbS5zYXAuc2FpbGluZy5nd3QudWkuU3BlY3RhdG9yPC9lbnRyeS1wb2ludC1tb2R1bGU+PC9nd3QtY29tcGlsZS1zZXR0aW5ncz4\=
|
||||
+4
@@ -8,6 +8,7 @@ import java.util.Map;
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||
import com.sap.sailing.domain.common.NoWindException;
|
||||
import com.sap.sailing.domain.common.Placemark;
|
||||
import com.sap.sailing.domain.common.WindSource;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.gwt.ui.shared.CompetitorDAO;
|
||||
@@ -36,6 +37,9 @@ import com.sap.sailing.server.api.RaceIdentifier;
|
||||
*/
|
||||
@RemoteServiceRelativePath("sailing")
|
||||
public interface SailingService extends RemoteService {
|
||||
//
|
||||
Placemark testPlacemarkSerialization();
|
||||
//
|
||||
List<TracTracConfigurationDAO> getPreviousTracTracConfigurations() throws Exception;
|
||||
|
||||
List<EventDAO> listEvents(boolean withRacePlaces);
|
||||
|
||||
+5
@@ -7,6 +7,7 @@ import java.util.Map;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sap.sailing.domain.base.Course;
|
||||
import com.sap.sailing.domain.common.Placemark;
|
||||
import com.sap.sailing.domain.common.WindSource;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.domain.leaderboard.RaceInLeaderboard;
|
||||
@@ -36,6 +37,9 @@ import com.sap.sailing.server.api.RaceIdentifier;
|
||||
* The async counterpart of {@link SailingService}
|
||||
*/
|
||||
public interface SailingServiceAsync {
|
||||
//
|
||||
void testPlacemarkSerialization(AsyncCallback<Placemark> callback);
|
||||
//
|
||||
|
||||
void listEvents(boolean withRacePlaces, AsyncCallback<List<EventDAO>> callback);
|
||||
|
||||
@@ -253,4 +257,5 @@ public interface SailingServiceAsync {
|
||||
* mark passing times, the race start time and the list of time points according to the above specification.
|
||||
*/
|
||||
void getCompetitorsAndTimePoints(RaceIdentifier race, int steps, AsyncCallback<CompetitorsAndTimePointsDAO> callback);
|
||||
|
||||
}
|
||||
+9
@@ -53,6 +53,7 @@ import com.sap.sailing.domain.common.Distance;
|
||||
import com.sap.sailing.domain.common.LegType;
|
||||
import com.sap.sailing.domain.common.NoWindError;
|
||||
import com.sap.sailing.domain.common.NoWindException;
|
||||
import com.sap.sailing.domain.common.Placemark;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.Speed;
|
||||
import com.sap.sailing.domain.common.Tack;
|
||||
@@ -130,6 +131,13 @@ import com.sap.sailing.server.api.RaceIdentifier;
|
||||
* The server side implementation of the RPC service.
|
||||
*/
|
||||
public class SailingServiceImpl extends RemoteServiceServlet implements SailingService, RaceFetcher, EventFetcher {
|
||||
//
|
||||
@Override
|
||||
public Placemark testPlacemarkSerialization() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
//
|
||||
private static final Logger logger = Logger.getLogger(SailingServiceImpl.class.getName());
|
||||
|
||||
private static final long serialVersionUID = 9031688830194537489L;
|
||||
@@ -1585,4 +1593,5 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
//Override to prevent exception "Blocked request without GWT permutation header (XSRF attack?)" when testing the GWT sites
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -285,11 +285,11 @@ public class OverviewEventPanel extends AbstractEventPanel {
|
||||
public void onSuccess(List<EventDAO> result) {
|
||||
if (result != null) {
|
||||
availableEvents = new ArrayList<EventDAO>(result);
|
||||
eventTableProvider.getList().clear();
|
||||
eventTableProvider.setList(availableEvents);
|
||||
} else {
|
||||
availableEvents.clear();
|
||||
}
|
||||
eventTableProvider.getList().clear();
|
||||
eventTableProvider.setList(availableEvents);
|
||||
if (actionAfterLoading != null) {
|
||||
actionAfterLoading.run();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user