Skip to content

Instantly share code, notes, and snippets.

@ejain
Last active December 25, 2015 21:43
Show Gist options
  • Save ejain/ea143f446bb568ec20d6 to your computer and use it in GitHub Desktop.
Save ejain/ea143f446bb568ec20d6 to your computer and use it in GitHub Desktop.
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