Example #1
0
    def writeToGpx(tracks, path, af=False):
        """
        Transforms track into Gpx string
        # path: file to write gpx (gpx returned in standard output if empty)
        af: AF exported in gpx file
        """
        f = open(path, "w")

        # Time output management
        fmt_save = GPSTime.getPrintFormat()
        GPSTime.setPrintFormat("4Y-2M-2DT2h:2m:2s")

        if isinstance(tracks, Track):
            collection = TrackCollection()
            collection.addTrack(tracks)
            tracks = collection

        f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
        f.write("<gpx>\n")
        f.write(
            "<author>File generated by Tracklib: https://github.com/umrlastig/tracklib</author>\n"
        )
        for i in range(len(tracks)):
            track = tracks.getTrack(i)
            f.write("    <trk>\n")
            f.write("        <trkseg>\n")
            for i in range(len(track)):
                x = "{:3.8f}".format(track[i].position.getX())
                y = "{:3.8f}".format(track[i].position.getY())
                z = "{:3.8f}".format(track[i].position.getZ())
                f.write('            <trkpt lat="' + y + '" lon="' + x +
                        '">\n')
                f.write("                <ele>" + z + "</ele>\n")
                f.write("                <time>" + str(track[i].timestamp) +
                        track[i].timestamp.printZone() + "</time>\n")
                if af:
                    f.write("                <extensions>\n")
                    for af_name in track.getListAnalyticalFeatures():
                        f.write("                    <" + af_name + ">")
                        f.write(str(track.getObsAnalyticalFeature(af_name, i)))
                        f.write("</" + af_name + ">\n")
                    f.write("                </extensions>\n")
                f.write("            </trkpt>\n")
            f.write("        </trkseg>\n")
            f.write("    </trk>\n")
        f.write("</gpx>\n")

        f.close()
        GPSTime.setPrintFormat(fmt_save)
Example #2
0
from tracklib.core.Obs import Obs
from tracklib.core.Operator import Operator
from tracklib.core.Kernel import GaussianKernel
from tracklib.io.FileReader import FileReader

import sys
import math
import time
import random
import numpy as np

# ---------------------------------------------------
# Lecture des donnees
# ---------------------------------------------------
GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")
GPSTime.setPrintFormat("4Y-2M-2D 2h:2m:2s.3z")

chemin = "../data/trace0.gps"

GPSTime.setReadFormat("4Y-2M-2D 2h:2m:2s")

track = FileReader.readFromFile(chemin, 2, 3, -1, 1, separator=",")

track = track.extract(100, 300)
track %= 20

#			- MODE_SPATIAL        (1)
#			- MODE_TEMPORAL       (2)
#		algorithm:
#			- ALGO_LINEAR            (1)
#			- ALGO_THIN_SPLINES      (2)