Matcher commentMatcher = COMMENT_LINE_PATTERN.matcher(line);
if (commentMatcher.matches()) {
String latitude = commentMatcher.group(1);
String longitude = commentMatcher.group(2);
String description = commentMatcher.group(3);
return new Wgs84Position(parseDouble(longitude), parseDouble(latitude), null, null, null, trim(description));
}
Matcher simpleMatcher = SIMPLE_LINE_PATTERN.matcher(line);
if (simpleMatcher.matches()) {
String latitude = simpleMatcher.group(1);
String longitude = simpleMatcher.group(2);
return new Wgs84Position(parseDouble(longitude), parseDouble(latitude), null, null, null, null);
}
throw new IllegalArgumentException("'" + line + "' does not match");
}