Trees | Indices | Help |
|
---|
|
object --+ | list --+ | point.Points --+ | Waypoints
Since: 0.8.0
|
|||
new list |
|
||
list
|
|
||
ET.ElementTree |
|
||
Inherited from Inherited from Inherited from |
|
|||
Inherited from |
|
|
Import GPX data files import_locations() returns a list with Waypoint objects. It expects data files in GPX format, as specified in GPX 1.1 Schema Documentation, which is XML such as: <?xml version="1.0" encoding="utf-8" standalone="no"?> <gpx version="1.1" creator="PocketGPSWorld.com" xmlns="http://www.topografix.com/GPX/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"> <wpt lat="52.015" lon="-0.221"> <name>Home</name> <desc>My place</desc> </wpt> <wpt lat="52.167" lon="0.390"> <name>MSR</name> <desc>Microsoft Research, Cambridge</desc> </wpt> </gpx> The reader uses Python's ElementTree
module, so should be very fast when importing data. The above file
processed by import_locations() will return the following [Waypoint(52.015, -0.221, "Home", "My place"), Waypoint(52.167, 0.390, "MSR", "Microsoft Research, Cambridge")] >>> waypoints = Waypoints(open("gpx")) >>> for value in sorted(waypoints, ... key=lambda x: x.name.lower()): ... print(value) Home (52°00'54"N, 000°13'15"W) [My place] MSR (52°10'01"N, 000°23'24"E) [Microsoft Research, Cambridge]
|
Generate GPX element tree from Waypoints object >>> from sys import stdout >>> locations = Waypoints(open("gpx")) >>> xml = locations.export_gpx_file() >>> xml.write(stdout) <ns0:gpx xmlns:ns0="http://www.topografix.com/GPX/1/1"><ns0:wpt lat="52.015" lon="-0.221"><ns0:name>Home</ns0:name><ns0:desc>My place</ns0:desc></ns0:wpt><ns0:wpt lat="52.167" lon="0.39"><ns0:name>MSR</ns0:name><ns0:desc>Microsoft Research, Cambridge</ns0:desc></ns0:wpt></ns0:gpx>
|
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue May 20 12:41:18 2008 | http://epydoc.sourceforge.net |