# usage: awk -f GPX2OSM.awk gpx-input-file > osm-output-file BEGIN { FS = "[ \"<>]" node_id = 0 way_id = 0 printf "" printf "" } /\n", node_id, lat, lon } /\n", node_id, lat, lon } // { way_id++ node_count = 0 } /<\/trk>/ { if (node_count > 0) { printf " \n", way_id for (i = 0; i < node_count; i++) { printf " \n", nodes_in_way[i] } printf " \n" printf " " } } END { print "" }