Merge branch 'master' into bug4522

Change-Id: I566b40783ecf3fbb9b724990e2fb4e455cec15e3
This commit is contained in:
Axel Uhl committed 2018-04-25 11:44:31 +02:00
commit 8f9ed7074d
2 files changed
+45 -25

No files matched your search

@@ -7,6 +7,7 @@ import java.io.InputStreamReader;
import java.io.Serializable;
import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collections;
@@ -217,10 +218,6 @@ public class ExpeditionExtendedDataImporterImpl extends AbstractDoubleVectorFixI
Map<String, Integer> columnsInFileFromHeader, LineParserCallback callback) {
try {
String[] lineContentTokens = split(line);
final TimePoint timePoint;
final String date;
final String dateFormatPattern;
final Integer boatColumnIndex = columnsInFileFromHeader.get(BOAT_COL);
if (boatColumnIndex != null) {
// Not all file types contain a boat column.
@@ -231,27 +228,7 @@ public class ExpeditionExtendedDataImporterImpl extends AbstractDoubleVectorFixI
return;
}
}
if (columnsInFileFromHeader.containsKey(UTC_COLUMN)) {
timePoint = getTimePoint(lineContentTokens[columnsInFileFromHeader.get(UTC_COLUMN)]);
} else if (columnsInFileFromHeader.containsKey(DATE_COLUMN_1)
|| columnsInFileFromHeader.containsKey(DATE_COLUMN_2)) {
if (columnsInFileFromHeader.containsKey(DATE_COLUMN_1)) {
date = lineContentTokens[columnsInFileFromHeader.get(DATE_COLUMN_1)];
dateFormatPattern = DATE_COLUMN_1_PATTERN;
} else {
date = lineContentTokens[columnsInFileFromHeader.get(DATE_COLUMN_2)];
dateFormatPattern = DATE_COLUMN_2_PATTERN;
}
final String time = lineContentTokens[columnsInFileFromHeader.get(TIME_COLUMN)];
final DateFormat df = new SimpleDateFormat(dateFormatPattern + "'T'HH:mm:ssX");
final Date timestamp = df.parse(date + "T" + time + "+00:00"); // assuming
// UTC
timePoint = new MillisecondsTimePoint(timestamp);
} else {
// assume that "GPS Time" is present:
timePoint = getTimePoint(lineContentTokens[columnsInFileFromHeader.get(GPS_TIME_COLUMN)]);
}
final TimePoint timePoint = getTimePointFromLine(columnsInFileFromHeader, lineContentTokens);
if (timePoint != null) {
callback.accept(timePoint, lineContentTokens, columnsInFileFromHeader);
}
@@ -261,6 +238,47 @@ public class ExpeditionExtendedDataImporterImpl extends AbstractDoubleVectorFixI
}
}
/**
* Obtains the time from a line from the Expedition log file. Three time sources are considered in the following
* order of decreasing precedence:
* <ol>
* <li>{@code GPS Time}: the time as reported by the GPS device, in an Excel-like format as days since the
* epoch</li>
* <li>{@code Utc}: the time as reported by the computer Expedition was running on when recording the log, in an
* Excel-like format as days since the epoch</li>
* <li>{@code dd/mm/yy + hhmmss} or {@code mm/dd/yy + hhmmss}: an unknown time source, probably from the computer
* Expedition was running on when the log was recorded; assumed to be reported in UTC</li>
* </ol>
* If none of the above is found, {@link null} is returned.
*/
protected static TimePoint getTimePointFromLine(Map<String, Integer> columnsInFileFromHeader,
String[] lineContentTokens) throws ParseException {
final TimePoint timePoint;
final String date;
final String dateFormatPattern;
if (columnsInFileFromHeader.containsKey(GPS_TIME_COLUMN)) {
timePoint = getTimePoint(lineContentTokens[columnsInFileFromHeader.get(GPS_TIME_COLUMN)]);
} else if (columnsInFileFromHeader.containsKey(UTC_COLUMN)) {
timePoint = getTimePoint(lineContentTokens[columnsInFileFromHeader.get(UTC_COLUMN)]);
} else if (columnsInFileFromHeader.containsKey(DATE_COLUMN_1)
|| columnsInFileFromHeader.containsKey(DATE_COLUMN_2)) {
if (columnsInFileFromHeader.containsKey(DATE_COLUMN_1)) {
date = lineContentTokens[columnsInFileFromHeader.get(DATE_COLUMN_1)];
dateFormatPattern = DATE_COLUMN_1_PATTERN;
} else {
date = lineContentTokens[columnsInFileFromHeader.get(DATE_COLUMN_2)];
dateFormatPattern = DATE_COLUMN_2_PATTERN;
}
final String time = lineContentTokens[columnsInFileFromHeader.get(TIME_COLUMN)];
final DateFormat df = new SimpleDateFormat(dateFormatPattern + "'T'HH:mm:ssX");
final Date timestamp = df.parse(date + "T" + time + "+00:00"); // assuming UTC
timePoint = new MillisecondsTimePoint(timestamp);
} else {
timePoint = null;
}
return timePoint;
}
/**
* The 1900 Date System http://support.microsoft.com/kb/180162/en-us
*/
@@ -33,6 +33,8 @@
Expedition specific measures - if available - are shown at the end of the list.</li>
<li>The all in one expedition import has been extended to be able to import new competitor tracks or new races to an existing regatta.
Previously it was only possible to import a new event structure.</li>
<li>The Expedition log file import now prefers "GPS Time" for time stamping over "Utc" and over other date / time formats, making it
more consistent with the Expedition live connector which uses column 146 for time stamping which is GPS Time.</li>
</ul>
<h2 class="articleSubheadline">March 2018</h2>