if (matcher.matches()) {
position.setTime(parseTripmaster14Time(matcher.group(2)));
position.setElevation(parseDouble(matcher.group(3)));
if (position instanceof TomTomPosition) {
TomTomPosition tomTomPosition = (TomTomPosition) position;
String reason = trim(matcher.group(1));
tomTomPosition.setReason(reason);
tomTomPosition.setHeading(parseTripmasterHeading(reason));
tomTomPosition.setCity(trim(matcher.group(4)));
}
if (position instanceof Wgs84Position) {
Wgs84Position wgs84Position = (Wgs84Position) position;
String reason = trim(matcher.group(1));
wgs84Position.setHeading(parseTripmasterHeading(reason));
}
}
matcher = TRIPMASTER_18_SHORT_STARTEND_PATTERN.matcher(comment);
if (matcher.matches()) {
String dateStr = trim(matcher.group(4));
String timeStr = trim(matcher.group(5));
position.setTime(parseTripmaster18Date(dateStr + " " + timeStr));
if (!position.hasTime())
position.setTime(parseTripmaster14Time(timeStr));
position.setElevation(parseDouble(matcher.group(6)));
if (position instanceof TomTomPosition) {
TomTomPosition tomTomPosition = (TomTomPosition) position;
String city = trim(matcher.group(3));
if (city == null) {
city = dateStr;
dateStr = null;
}
tomTomPosition.setReason(trim(matcher.group(1)) + " : " + (dateStr != null ? dateStr + " - " : "") + timeStr);
tomTomPosition.setCity(city);
}
}
matcher = TRIPMASTER_18_SHORT_WAYPOINT_PATTERN.matcher(comment);
if (matcher.matches()) {
position.setTime(parseTripmaster14Time(matcher.group(1)));
position.setElevation(parseDouble(matcher.group(2)));
if (position instanceof TomTomPosition) {
TomTomPosition tomTomPosition = (TomTomPosition) position;
tomTomPosition.setReason("Waypoint");
tomTomPosition.setCity(null);
}
}
matcher = TRIPMASTER_25_SHORT_WAYPOINT_PATTERN.matcher(comment);
if (matcher.matches()) {
position.setTime(parseTripmaster14Time(trim(matcher.group(1))));
position.setElevation(parseDouble(matcher.group(3)));
if (position instanceof TomTomPosition) {
TomTomPosition tomTomPosition = (TomTomPosition) position;
String reason = trim(matcher.group(2));
tomTomPosition.setReason(reason);
tomTomPosition.setHeading(parseTripmasterHeading(reason));
tomTomPosition.setCity(null);
}
if (position instanceof Wgs84Position) {
Wgs84Position wgs84Position = (Wgs84Position) position;
String reason = trim(matcher.group(2));
wgs84Position.setHeading(parseTripmasterHeading(reason));
}
}
matcher = TRIPMASTER_25_SHORT_STARTEND_PATTERN.matcher(comment);
if (matcher.matches()) {
String dateStr = trim(matcher.group(4));
String timeStr = trim(matcher.group(5));
position.setTime(parseTripmaster18Date(dateStr + " " + timeStr));
position.setElevation(parseDouble(matcher.group(6)));
if (position instanceof TomTomPosition) {
TomTomPosition tomTomPosition = (TomTomPosition) position;
String reason = trim(matcher.group(2));
tomTomPosition.setReason(reason);
tomTomPosition.setCity(null);
}
}
matcher = TRIPMASTER_31_SHORT_STARTEND_PATTERN.matcher(comment);
if (matcher.matches()) {
String dateStr = trim(matcher.group(4));
String timeStr = trim(matcher.group(5));
position.setTime(parseTripmaster18Date(dateStr + " " + timeStr));
position.setElevation(parseDouble(matcher.group(6)));
if (position instanceof TomTomPosition) {
TomTomPosition tomTomPosition = (TomTomPosition) position;
String reason = trim(matcher.group(2));
tomTomPosition.setReason(reason);
tomTomPosition.setCity(null);
}
}
matcher = TRIPMASTER_MIDDLE_PATTERN.matcher(comment);
if (matcher.matches()) {
position.setTime(parseTripmaster14Time(trim(matcher.group(1))));
position.setElevation(parseDouble(matcher.group(4)));
if (position instanceof TomTomPosition) {
TomTomPosition tomTomPosition = (TomTomPosition) position;
String city = trim(matcher.group(3));
if (city != null && city.startsWith(": "))
city = trim(city.substring(2, city.length()));
String reason = trim(matcher.group(2));
if (reason == null)
reason = city;
tomTomPosition.setCity(city);
tomTomPosition.setReason(reason);
}
}
matcher = TRIPMASTER_LONG_NO_REASON_PATTERN.matcher(comment);
if (matcher.matches()) {
position.setTime(parseTripmaster14Time(trim(matcher.group(1))));
position.setSpeed(parseDouble(matcher.group(6)));
position.setElevation(parseDouble(matcher.group(3)));
if (position instanceof TomTomPosition) {
TomTomPosition tomTomPosition = (TomTomPosition) position;
String city = trim(matcher.group(2));
if (city != null && city.startsWith(": "))
city = trim(city.substring(2, city.length()));
tomTomPosition.setCity(city);
tomTomPosition.setReason(city);
}
}
matcher = TRIPMASTER_LONG_PATTERN.matcher(comment);
if (matcher.matches()) {
position.setTime(parseTripmaster18Date(matcher.group(3)));
if (!position.hasTime())
position.setTime(parseTripmaster14Time(matcher.group(1)));
position.setSpeed(parseDouble(matcher.group(9)));
position.setElevation(parseDouble(matcher.group(6)));
if (position instanceof TomTomPosition) {
TomTomPosition tomTomPosition = (TomTomPosition) position;
String city = trim(matcher.group(5));
if (city != null && city.startsWith(": "))
city = trim(city.substring(2, city.length()));
String reason = trim(matcher.group(2));
if (city == null)
city = reason;
tomTomPosition.setCity(city);
tomTomPosition.setReason(reason);
}
}
matcher = LOGPOS_2_PATTERN.matcher(comment);
if (matcher.matches()) {
position.setTime(parseLogposDate(matcher.group(1)));
position.setSpeed(parseDouble(matcher.group(5)));
if (position instanceof TomTomPosition) {
TomTomPosition tomTomPosition = (TomTomPosition) position;
tomTomPosition.setReason(trim(matcher.group(4)));
tomTomPosition.setCity(trim(matcher.group(3)));
tomTomPosition.setHeading(parseDouble(matcher.group(6)));
}
}
matcher = LOGPOS_1_PATTERN.matcher(comment);
if (matcher.matches()) {
position.setTime(parseLogposDate(matcher.group(1)));
Double elevation;
try {
elevation = parseDouble(matcher.group(4));
} catch (NumberFormatException e) {
elevation = null;
}
position.setElevation(elevation);
position.setSpeed(parseDouble(matcher.group(7)));
if (position instanceof TomTomPosition) {
TomTomPosition tomTomPosition = (TomTomPosition) position;
tomTomPosition.setReason(trim(matcher.group(5)));
tomTomPosition.setCity(trim(matcher.group(3)));
tomTomPosition.setHeading(parseDouble(matcher.group(8)));
}
}
matcher = TTTRACKLOG_PATTERN.matcher(comment);
if (matcher.matches()) {
position.setTime(parseTTTracklogTime(matcher.group(1)));
position.setSpeed(parseDouble(matcher.group(5)));
Double elevation = parseDouble(matcher.group(6));
if(elevation == null)
elevation = parseDouble(matcher.group(4)); // pause with elevation
position.setElevation(elevation);
if (position instanceof TomTomPosition) {
TomTomPosition tomTomPosition = (TomTomPosition) position;
tomTomPosition.setReason(trim(matcher.group(2)));
}
}
matcher = ROUTECONVERTER_STARTEND_PATTERN.matcher(comment);
if (matcher.matches()) {
String dateStr = trim(matcher.group(4));
String timeStr = trim(matcher.group(5));
position.setTime(parseTripmaster18Date(dateStr + " " + timeStr));
position.setElevation(parseDouble(matcher.group(6)));
position.setSpeed(parseDouble(matcher.group(7)));
if (position instanceof TomTomPosition) {
TomTomPosition tomTomPosition = (TomTomPosition) position;
String reason = trim(matcher.group(2));
tomTomPosition.setReason(reason);
String city = trim(matcher.group(3));
tomTomPosition.setCity(city);
tomTomPosition.setHeading(parseDouble(matcher.group(9)));
}
}
matcher = ROUTECONVERTER_INTERMEDIATE_PATTERN.matcher(comment);
if (matcher.matches()) {
String timeStr = trim(matcher.group(2));
position.setTime(parseTripmaster14Time(timeStr));
position.setElevation(parseDouble(matcher.group(3)));
position.setSpeed(parseDouble(matcher.group(4)));
if (position instanceof TomTomPosition) {
TomTomPosition tomTomPosition = (TomTomPosition) position;
String city = trim(matcher.group(1));
tomTomPosition.setCity(city);
tomTomPosition.setHeading(parseDouble(matcher.group(6)));
}
}
}