return gpx;
}
private Gpx createGpx(List<GpxRoute> routes) {
ObjectFactory objectFactory = new ObjectFactory();
Gpx gpx = null;
for(GpxRoute route : routes) {
gpx = recycleGpx(route);
if(gpx != null)
break;
}
if (gpx == null || !reuseReadObjectsForWriting)
gpx = objectFactory.createGpx();
gpx.setCreator(GENERATED_BY);
gpx.setVersion(VERSION);
for (GpxRoute route : routes) {
switch (route.getCharacteristics()) {
case Waypoints:
createMetaData(route, gpx);
gpx.getWpt().addAll(createWayPoints(route, 0, route.getPositionCount()));
break;
case Route:
gpx.getRte().addAll(createRoute(route, 0, route.getPositionCount()));
break;
case Track:
gpx.getTrk().addAll(createTrack(route, 0, route.getPositionCount()));
break;
default:
throw new IllegalArgumentException("Unknown RouteCharacteristics " + route.getCharacteristics());
}
}