FlightPlan flightPlan = unmarshal(source);
context.appendRoute(process(flightPlan));
}
private FlightPlan createFpl(GarminFlightPlanRoute route, int startIndex, int endIndex) {
ObjectFactory objectFactory = new ObjectFactory();
FlightPlan flightPlan = objectFactory.createFlightPlan();
FlightPlan.Route flightPlanRoute = objectFactory.createFlightPlanRoute();
flightPlanRoute.setRouteName(asRouteName(route.getName()));
flightPlanRoute.setRouteDescription(asDescription(route.getDescription()));
flightPlanRoute.setFlightPlanIndex((short) 1);
FlightPlan.WaypointTable waypointTable = objectFactory.createFlightPlanWaypointTable();
List<GarminFlightPlanPosition> positions = route.getPositions();
for (int i = startIndex; i < endIndex; i++) {
GarminFlightPlanPosition position = positions.get(i);
FlightPlan.Route.RoutePoint routePoint = objectFactory.createFlightPlanRouteRoutePoint();
String countryCode = "";
if (position.getCountryCode() != null && position.getWaypointType() != null && !position.getWaypointType().equals(UserWaypoint))
countryCode = position.getCountryCode().value();
routePoint.setWaypointCountryCode(countryCode);
routePoint.setWaypointIdentifier(position.getIdentifier());
if (position.getWaypointType() != null)
routePoint.setWaypointType(position.getWaypointType().value());
flightPlanRoute.getRoutePoint().add(routePoint);
FlightPlan.WaypointTable.Waypoint waypoint = objectFactory.createFlightPlanWaypointTableWaypoint();
waypoint.setComment(position.getDescription());
waypoint.setCountryCode(countryCode);
waypoint.setElevation(formatElevation(position.getElevation()));
waypoint.setIdentifier(position.getIdentifier());
waypoint.setLat(formatPosition(position.getLatitude()));