}
return kmlType;
}
private KmlType createKmlType(List<KmlRoute> routes) {
ObjectFactory objectFactory = new ObjectFactory();
KmlType kmlType = objectFactory.createKmlType();
DocumentType documentType = objectFactory.createDocumentType();
kmlType.setAbstractFeatureGroup(objectFactory.createDocument(documentType));
documentType.setOpen(TRUE);
documentType.getAbstractStyleSelectorGroup().add(objectFactory.createStyle(createLineStyle(ROUTE_LINE_STYLE, getLineWidth(), getRouteLineColor())));
documentType.getAbstractStyleSelectorGroup().add(objectFactory.createStyle(createLineStyle(TRACK_LINE_STYLE, getLineWidth(), getTrackLineColor())));
if (isWriteSpeed())
for (StyleType style : createSpeedTrackColors(getSpeedLineWidth()))
documentType.getAbstractStyleSelectorGroup().add(objectFactory.createStyle(style));
for (KmlRoute route : routes) {
switch (route.getCharacteristics()) {
case Waypoints:
FolderType wayPoints = createWayPoints(route, 0, route.getPositionCount());
documentType.getAbstractFeatureGroup().add(objectFactory.createFolder(wayPoints));
break;
case Route:
FolderType routeFolder = objectFactory.createFolderType();
routeFolder.setName(createPlacemarkName(ROUTE, route));
documentType.getAbstractFeatureGroup().add(objectFactory.createFolder(routeFolder));
PlacemarkType routePlacemarks = createRoute(route);
routeFolder.getAbstractFeatureGroup().add(objectFactory.createPlacemark(routePlacemarks));
if (isWriteMarks())
routeFolder.getAbstractFeatureGroup().add(objectFactory.createFolder(createMarks(route, 0, route.getPositionCount())));
break;
case Track:
FolderType trackFolder = objectFactory.createFolderType();
trackFolder.setName(createPlacemarkName(TRACK, route));
documentType.getAbstractFeatureGroup().add(objectFactory.createFolder(trackFolder));
PlacemarkType track = createTrack(route, 0, route.getPositionCount());
trackFolder.getAbstractFeatureGroup().add(objectFactory.createPlacemark(track));
if (isWriteSpeed()) {
FolderType speed = createSpeed(route, 0, route.getPositionCount());
if (speed != null)
trackFolder.getAbstractFeatureGroup().add(objectFactory.createFolder(speed));
}
if (isWriteMarks())
trackFolder.getAbstractFeatureGroup().add(objectFactory.createFolder(createMarks(route, 0, route.getPositionCount())));
break;
default:
throw new IllegalArgumentException("Unknown RouteCharacteristics " + route.getCharacteristics());
}
}