コード例 #1
0
def transform_kmls_to_gpxs(directory):
    kml_files = glob.glob("{}*.kml".format(directory))
    for kml_file in kml_files:
        file_name = splitext(basename(kml_file))
        doc = None
        with open(kml_file) as in_f:
            doc = Document.readKML(in_f)

        with open("{}{}.gpx".format(directory, file_name[0]), 'w') as out:
            Document.writeGPX(doc, out)
コード例 #2
0
    def save(self):
        # create gpx document from existing gpx file
        today = datetime.date.today().strftime("%Y-%m-%d")
        gpx_file = os.path.join(self.directory, today + '.xml')
        document = Document(children=[], name=today)
        if os.path.exists(gpx_file):
            document = document.readGPX(gpx_file)

        # add track to document
        segment = TrackSegment(points=self.track_points)
        document.append(Track(segments=[segment]))

        # add way points to document
        for wp in self.way_points:
            document.append(wp)

        # write or overwrite gpx file
        f = open(gpx_file, "wb")
        f.write(document.toGPX().toprettyxml(encoding="utf-8"))
        f.close()

        self.track_points = []
        self.way_points = []
コード例 #3
0
ファイル: gpx2ovl.py プロジェクト: MauriceS/gpxdata
#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
# ----------------------------------------
# Copyright (C) 2008-2010  Frank Pählke
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
# ----------------------------------------

import sys
from os.path import basename
from gpxdata import Document

doc = Document.readGPX (sys.argv[1], basename(sys.argv[1]))
doc.writeOVL (sys.stdout)
コード例 #4
0
ファイル: kml2gpx.py プロジェクト: MauriceS/gpxdata
#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
# ----------------------------------------
# Copyright (C) 2008-2010  Frank Pählke
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
# ----------------------------------------

import sys
from os.path import basename
from gpxdata import Document

doc = Document.readKML (sys.argv[1])
doc.writeGPX (sys.stdout)
コード例 #5
0
ファイル: gpx_logger.py プロジェクト: erazor83/PenguPilot
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details. """


import sys
import zmq
from gps_data_pb2 import GpsData
from gpxdata import TrackPoint, TrackSegment, Track, Document
from zmq_ipc import generate_map


socket = generate_map('gpx_logger')['gps']
gps_data = GpsData()
segment = TrackSegment()
try:
   while True:
      str = socket.recv()
      gps_data.ParseFromString(str)
      print gps_data
      point = TrackPoint(gps_data.lat, gps_data.lon, gps_data.alt)
      segment.appendPoint(point)
except:
   pass

track = Track(name = "Copter Track", description = "Track recorded using the copter's onboard GPS module")
track.appendSegment(segment)
doc = Document([track], name = "Copter GPX Document")
doc.writeGPX(sys.stdout)

コード例 #6
0
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details. """

import sys
import zmq
from gps_data_pb2 import GpsData
from gpxdata import TrackPoint, TrackSegment, Track, Document
from zmq_ipc import generate_map

socket = generate_map('gpx_logger')['gps']
gps_data = GpsData()
segment = TrackSegment()
try:
    while True:
        str = socket.recv()
        gps_data.ParseFromString(str)
        print gps_data
        point = TrackPoint(gps_data.lat, gps_data.lon, gps_data.alt)
        segment.appendPoint(point)
except:
    pass

track = Track(
    name="Copter Track",
    description="Track recorded using the copter's onboard GPS module")
track.appendSegment(segment)
doc = Document([track], name="Copter GPX Document")
doc.writeGPX(sys.stdout)
コード例 #7
0
ファイル: kml2gpx.py プロジェクト: ucgmsim/TechPlatform2
#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
# ----------------------------------------
# Copyright (C) 2008-2010  Frank Pählke
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
# ----------------------------------------

import sys
from os.path import basename
from gpxdata import Document

doc = Document.readKML(sys.argv[1])
doc.writeGPX(sys.stdout)
コード例 #8
0
ファイル: ovl2gpx.py プロジェクト: MauriceS/gpxdata
#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
# ----------------------------------------
# Copyright (C) 2008-2010  Frank Pählke
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
# ----------------------------------------

import sys
from os.path import basename
from gpxdata import Document

doc = Document.readOVL (sys.argv[1], basename(sys.argv[1]))
doc.writeGPX (sys.stdout)