Create a gist now

Instantly share code, notes, and snippets.

Concatenates tracklogs from FlightAware for import into Google Fusion Tables.
import groovy.xml.MarkupBuilder
new MarkupBuilder().kml(xmlns : 'http://www.opengis.net/kml/2.2') {
Document() {
new File(args?.size() ? args[0] : '.').eachFileMatch(~/.*\.flight\.kml/) { file ->
new XmlParser().parse(file).Document.Placemark.each { placemark ->
placemark.Point.each { point ->
Placemark {
name(placemark.name.text())
Point {
coordinates(point.coordinates.text());
}
}
}
placemark.'gx:Track'.each { track ->
Placemark {
name(placemark.name.text())
LineString {
coordinates(track.'gx:coord'.collect { it.text().replace(' ', ',') }.join("\n"));
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment