}
public GarminFlightPlanPosition asGarminFlightPlanPosition() {
GarminFlightPlanPosition position = new GarminFlightPlanPosition(getLongitude(), getLatitude(), getElevation(), getDescription());
position.setWaypointType(UserWaypoint);
WptType wptType = getOrigin(WptType.class);
if (wptType != null) {
String type = trim(wptType.getType());
if (type != null) {
WaypointType waypointType = WaypointType.fromValue(type);
position.setWaypointType(waypointType);
String name = wptType.getName();
if (name != null && name.length() >= 2)
position.setCountryCode(CountryCode.fromValue(name.substring(0, 2)));
}
String description = trim(wptType.getCmt());
if (description != null) {
position.setDescription(description);
}
}
return position;