From OpenStreetMap Wiki
Jump to: navigation, search

ovl to gpx converter

I searched for a simple system-independent OVL to GPX converter and found none. So I wrote one in Python.

Here is the source code. Licence: GPLv2 Author: Segatus (Volker Paul in real life).

See [1] if you do not know or have Python yet.

#! /usr/bin/env python
# -*- coding: utf-8 -*-

"""Convert .ovl file to .gpx.
Usage: python ovl2gpx.py wanderweg.ovl >wanderweg.gpx

import sys

def main():
    f = open(sys.argv[1], 'r')
    print """<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" creator="" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
    for line in f:
        attr = line.split('=')[0]
        if attr[0:6] == 'XKoord':  x = line.split('=')[1][:-2]
        # Line seems to have 2 chars for line end marker.
        if attr[0:6] == 'YKoord':  
            y = line.split('=')[1][:-2]
            print '<trkpt lat="%s" lon="%s"></trkpt>' % (y, x)
    print "</trkseg></trk></gpx>"

if __name__ == "__main__":