Last active
December 25, 2015 21:43
-
-
Save ejain/ea143f446bb568ec20d6 to your computer and use it in GitHub Desktop.
Concatenates tracklogs from FlightAware for import into Google Fusion Tables.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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