}
public File publishKML() throws FileNotFoundException {
File outputFile = new File(ServletContextParameterMap.getParameterValue(ContextParameter.USER_DIRECTORY_PATH) + "KML/" + worksheet.getTitle() + ".kml");
final Kml kml = KmlFactory.createKml();
final Folder folder = kml.createAndSetFolder()
.withName(worksheet.getTitle()).withOpen(true);
Style style = folder.createAndAddStyle().withId("karma");
if(randomCounter++%2 == 0)
style.createAndSetIconStyle().withScale(1.399999976158142).withIcon(new Icon().withHref("http://maps.google.com/mapfiles/ms/icons/blue-pushpin.png"));
else
style.createAndSetIconStyle().withScale(1.399999976158142).withIcon(new Icon().withHref("http://maps.google.com/mapfiles/ms/icons/red-pushpin.png"));
for (edu.isi.karma.geospatial.Point point : points) {
folder.createAndAddPlacemark()
.withDescription(point.getHTMLDescription())
.withVisibility(true)
.withStyleUrl("karma")
.createAndSetPoint()
.withAltitudeMode(AltitudeMode.CLAMP_TO_GROUND)
.addToCoordinates(
point.getLongitude() + "," + point.getLatitude());
}
for (edu.isi.karma.geospatial.LineString line : lines) {
folder.createAndAddPlacemark()
.withDescription(line.getHTMLDescription())
.withVisibility(true).createAndSetLineString()
.withAltitudeMode(AltitudeMode.CLAMP_TO_GROUND)
.setCoordinates(line.getCoordinatesList());
}
int n=0;
for (Polygon polygon: polygons) {
FeatureTable featureTable = polygonTable.get(n);
Placemark placemark = folder.createAndAddPlacemark()
.withDescription(featureTable.getHTMLDescription())
.withVisibility(true);
final de.micromata.opengis.kml.v_2_2_0.Polygon kmlPolygon = new de.micromata.opengis.kml.v_2_2_0.Polygon();
placemark.setGeometry(kmlPolygon);