Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Converts a directory of GPX files into a single KML file for import into Google Fusion Tables; includes some metadata based on the file name.
import groovy.xml.MarkupBuilder
new MarkupBuilder().kml(xmlns : 'http://www.opengis.net/kml/2.2') {
new File(args?.size() ? args[0] : '.').eachFileMatch(~/.*\.gpx/) { file ->
new XmlParser().parse(file).trk.each { trk ->
trk.trkseg.each { trkseg ->
def geo = ""
trkseg.trkpt.each { trkpt ->
geo += "${trkpt.'@lon'},${trkpt.'@lat'}\n"
}
if (geo) {
Placemark() {
name(file.getName().substring(0, 8))
LineString {
coordinates(geo);
}
ExtendedData {
Data(name : 'mode') {
value(file.getName() =~ /car/ ? 'drive' : 'hike')
}
Data(name : 'mode_color') {
value(file.getName() =~ /car/ ? 'FF000080' : 'FFFF00FF')
}
Data(name : 'multiday') {
value(file.getName().contains('-'))
}
}
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.