mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-20 04:35:32 +00:00
avoid null points in additions to competitor charts
This commit is contained in:
+7
-5
@@ -1141,12 +1141,14 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
try {
|
||||
// Get distance to nearest placemark and calculate the search radius
|
||||
Placemark startNearest = ReverseGeocoder.INSTANCE.getPlacemarkNearest(startPosition);
|
||||
Distance startNearestDistance = startNearest.distanceFrom(startPosition);
|
||||
double startRadius = startNearestDistance.getKilometers() * GEONAMES_RADIUS_CACLCULATION_FACTOR;
|
||||
if (startNearest != null) {
|
||||
Distance startNearestDistance = startNearest.distanceFrom(startPosition);
|
||||
double startRadius = startNearestDistance.getKilometers() * GEONAMES_RADIUS_CACLCULATION_FACTOR;
|
||||
|
||||
// Get the estimated best start place
|
||||
startBest = ReverseGeocoder.INSTANCE.getPlacemarkLast(startPosition, startRadius,
|
||||
new Placemark.ByPopulationDistanceRatio(startPosition));
|
||||
// Get the estimated best start place
|
||||
startBest = ReverseGeocoder.INSTANCE.getPlacemarkLast(startPosition, startRadius,
|
||||
new Placemark.ByPopulationDistanceRatio(startPosition));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.throwing(TrackedRaceImpl.class.getName(), "getPlaceOrder()", e);
|
||||
} catch (ParseException e) {
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ public class ReverseGeocoderImpl implements ReverseGeocoder {
|
||||
p = cachedPlacemarks.getC().get(0);
|
||||
} else {
|
||||
JSONArray geonames = callNearestService(position);
|
||||
if (!geonames.isEmpty()) {
|
||||
if (geonames != null && !geonames.isEmpty()) {
|
||||
p = JSONToPlacemark((JSONObject) geonames.get(0));
|
||||
|
||||
if (p != null) {
|
||||
|
||||
+4
-5
@@ -300,17 +300,16 @@ implements CompetitorSelectionChangeListener, RaceSelectionChangeListener, TimeL
|
||||
Date dateOfNewestSeriesPoint = compSeriesPoints.length == 0 ? new Date(0) : new Date(
|
||||
compSeriesPoints[compSeriesPoints.length - 1].getX().longValue());
|
||||
List<Pair<Date, Double>> raceData = competitorData.getRaceDataAfterDate(dateOfNewestSeriesPoint);
|
||||
Point[] points = new Point[raceData.size()];
|
||||
int i=0;
|
||||
List<Point> points = new ArrayList<Point>();
|
||||
for (Pair<Date, Double> data : raceData) {
|
||||
if (data.getA() != null && data.getB() != null) {
|
||||
Point competitorPoint = new Point(data.getA().getTime(), data.getB());
|
||||
points[i++] = competitorPoint;
|
||||
points.add(competitorPoint);
|
||||
}
|
||||
}
|
||||
Point[] newPoints = new Point[compSeriesPoints.length + points.length];
|
||||
Point[] newPoints = new Point[compSeriesPoints.length + points.size()];
|
||||
System.arraycopy(compSeriesPoints, 0, newPoints, 0, compSeriesPoints.length);
|
||||
System.arraycopy(points, 0, newPoints, compSeriesPoints.length, points.length);
|
||||
System.arraycopy(points.toArray(), 0, newPoints, compSeriesPoints.length, points.size());
|
||||
compSeries.setPoints(newPoints);
|
||||
|
||||
//Adding the series if chart doesn't contain it
|
||||
|
||||
Reference in New Issue
Block a user