Permalink
Switch branches/tags
verified_ok_on_spIII_2_70 v1_3_0-GSAK20060829 v1_3_0-GSAK20060829a test_0424 st2gpx_0_4_1_from_james snapshot_20060521 magxfer_1_2_0 magxfer_1_1_0 magxfer_1_0_1 magxfer_1_0_0 magxfer_0_8_2 magxfer_0_8_1 magxfer_0_8_0 initial_import initial-v initial-rel gpsbabel_1_5_4 gpsbabel_1_5_3 gpsbabel_1_5_2 gpsbabel_1_5_1 gpsbabel_1_5_0 gpsbabel_1_5_0-beta20140302 gpsbabel_1_5_0-beta20140214 gpsbabel_1_4_4 gpsbabel_1_4_3 gpsbabel_1_4_3-beta20120114 gpsbabel_1_4_3-beta20111112 gpsbabel_1_4_2 gpsbabel_1_4_1 gpsbabel_1_4_0 gpsbabel_1_3_7-beta20100516 gpsbabel_1_3_7-beta20100215 gpsbabel_1_3_7-beta20100116 gpsbabel_1_3_7-beta20090906 gpsbabel_1_3_7-beta20090828 gpsbabel_1_3_7-beta20090808 gpsbabel_1_3_7-beta20090806 gpsbabel_1_3_7-beta20090708 gpsbabel_1_3_6 gpsbabel_1_3_6-beta20081006 gpsbabel_1_3_6-beta20080921 gpsbabel_1_3_6-beta20080821 gpsbabel_1_3_5 gpsbabel_1_3_5-beta20080305 gpsbabel_1_3_5-beta20080305c gpsbabel_1_3_5-beta20080305b gpsbabel_1_3_5-beta20080305a gpsbabel_1_3_5-beta20080217 gpsbabel_1_3_5-beta20080214 gpsbabel_1_3_5-beta20080131 gpsbabel_1_3_5-beta20080121 gpsbabel_1_3_5-beta20071219 gpsbabel_1_3_4 gpsbabel_1_3_4-beta20070711 gpsbabel_1_3_3 gpsbabel_1_3_2 gpsbabel_1_3_2-beta20061117 gpsbabel_1_3_2-beta20061117a gpsbabel_1_3_2-beta20061109 gpsbabel_1_3_1_1012 gpsbabel_1_3_1_1007 gpsbabel_1_3_1 gpsbabel_1_3_0 gpsbabel_1_2_9 gpsbabel_1_2_8_beta11012005 gpsbabel_1_2_8-beta20060701a gpsbabel_1_2_8-beta20060605 gpsbabel_1_2_8-beta20060219 gpsbabel_1_2_8-beta20060209 gpsbabel_1_2_8-beta12012005-clyde gpsbabel_1_2_8-beta11082005 gpsbabel_1_2_8-beta11072005 gpsbabel_1_2_8-beta11062005 gpsbabel_1_2_7 gpsbabel_1_2_6 gpsbabel_1_2_6-beta06082005 gpsbabel_1_2_6-beta06072005-gsak gpsbabel_1_2_6-beta05092005 gpsbabel_1_2_5 gpsbabel_1_2_5_beta12222004 gpsbabel_1_2_5_beta11012004 gpsbabel_1_2_5_beta03272005-c gpsbabel_1_2_5_beta03272005-b gpsbabel_1_2_5_beta03272005-a gpsbabel_1_2_4 gpsbabel_1_2_4_beta09202004 gpsbabel_1_2_4_beta07242004 gpsbabel_1_2_3 gpsbabel_1_2_3_beta04112004 gpsbabel_1_2_3_beta04092004 gpsbabel_1_2_2 gpsbabel_1_2_2_beta03182004 gpsbabel_1_2_2_beta03172004 gpsbabel_1_2_2_beta02222004 gpsbabel_1_2_2_beta0318c2004 gpsbabel_1_2_2_beta0318b2004 gpsbabel_1_2_2_beta0317a2004 gpsbabel_1_2_1 gpsbabel_1_2_1_beta01212004 gpsbabel_1_2_1_beta01072004
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
128 lines (101 sloc) 3.28 KB
/*
Read Vito SmartMap .vtt tracks
Copyright (C) 2007 Jeremy Ehrhardt, jeremye@caltech.edu
based on vitostc.c, which is
Copyright (C) 2005 Etienne TASSE
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., 59 Temple Place - Suite 330, Boston, MA 02111 USA
*/
#include "defs.h"
#include <cmath>
#define MYNAME "vitovtt"
#define TM_YEAR_ZERO 1900
#define TM_MONTH_ZERO 1
static gbfile* infile = nullptr;
static int count = 0;
static const int vitovtt_version = 3;
// static const size_tvitovtt_headersize = 16;
// static const size_tvitovtt_datasize = 32;
static const double vitovtt_latitudescale = 20000000.0;
static const double vitovtt_longitudescale = 10000000.0;
static const int vitovtt_secondscale = 30000000;
static const int vitovtt_microsecondscale = 30;
static void
rd_init(const QString& fname)
{
infile = gbfopen_le(fname, "rb", MYNAME);
}
static void
rd_deinit()
{
gbfclose(infile);
}
static void
vitovtt_read()
{
struct tm tmStruct;
memset(&tmStruct, 0, sizeof(tmStruct));
route_head* route_head = route_head_alloc();
track_add_head(route_head);
/* Read the header. */
int version = gbfgetint32(infile);
count = gbfgetint32(infile);
if (version != vitovtt_version) {
fatal("%s (%d) reading file. Unsupported version %d\n",
MYNAME, __LINE__, version);
}
while (count) {
/* Read an entry. */
int scaled_lat = gbfgetint32(infile);
int scaled_lon = gbfgetint32(infile);
double altitude = gbfgetflt(infile);
tmStruct.tm_year = gbfgetint16(infile) - TM_YEAR_ZERO;
tmStruct.tm_mon = gbfgetc(infile) - TM_MONTH_ZERO;
tmStruct.tm_mday = gbfgetc(infile);
tmStruct.tm_hour = gbfgetc(infile);
tmStruct.tm_min = gbfgetc(infile);
int scaled_sec = gbfgetint32(infile);
double speed = gbfgetflt(infile);
int course = gbfgetint16(infile);
int status = gbfgetint32(infile);
Waypoint* wpt_tmp = new Waypoint;
wpt_tmp->latitude= scaled_lat / vitovtt_latitudescale;
wpt_tmp->longitude= scaled_lon / vitovtt_longitudescale;
wpt_tmp->altitude= altitude;
tmStruct.tm_sec = scaled_sec / vitovtt_secondscale;
int microseconds = (scaled_sec % vitovtt_secondscale) / vitovtt_microsecondscale;
wpt_tmp->SetCreationTime(mkgmtime(&tmStruct), lround(microseconds/1000.0));
/*
* TODO: interpret speed, course, status
*/
(void) speed;
(void) course;
(void) status;
track_add_wpt(route_head, wpt_tmp);
count--;
}
}
ff_vecs_t vitovtt_vecs = {
ff_type_file,
{ ff_cap_none, ff_cap_read, ff_cap_none },
rd_init,
nullptr,
rd_deinit,
nullptr,
vitovtt_read,
nullptr,
nullptr,
nullptr,
CET_CHARSET_UTF8, 1/* do nothing | CET-REVIEW */
, NULL_POS_OPS,
nullptr
};