Fugawi Binary trk format

View: New views
3 Messages — Rating Filter:   Alert me  

Fugawi Binary trk format

by Jan Dittmer-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I deciphered the binary waypoint trk format used by
Fugawi (http://l4x.org/gps/fugawi_trk.html).
Attached is a patch to add support to gpsbabel.

Please let me know if the patch is ok and what can
be done to get it merged.

I tested it against some own files and some from the
web and import and export seem to just work.

Thanks,

Jan


Index: Makefile.in
===================================================================
RCS file: /cvsroot/gpsbabel/gpsbabel/Makefile.in,v
retrieving revision 1.163
diff -u -r1.163 Makefile.in
--- Makefile.in 6 Sep 2009 20:04:03 -0000 1.163
+++ Makefile.in 8 Sep 2009 09:05:46 -0000
@@ -64,6 +64,7 @@
  igo8.o gopal.o humminbird.o mapasia.o gnav_trl.o navitel.o ggv_ovl.o \
  jtr.o sbp.o sbn.o mmo.o skyforce.o itracku.o v900.o delbin.o \
  pocketfms_bc.o pocketfms_fp.o pocketfms_wp.o naviguide.o enigma.o vpl.o \
+ fugawi_trk.o
 
 FMTS=@FMTS@
 
Index: vecs.c
===================================================================
RCS file: /cvsroot/gpsbabel/gpsbabel/vecs.c,v
retrieving revision 1.209
diff -u -r1.209 vecs.c
--- vecs.c 18 Jul 2009 06:11:17 -0000 1.209
+++ vecs.c 8 Sep 2009 09:05:47 -0000
@@ -148,6 +148,7 @@
 extern ff_vecs_t mapasia_tr7_vecs;
 extern ff_vecs_t gnav_trl_vecs;
 extern ff_vecs_t navitel_trk_vecs;
+extern ff_vecs_t fugawitrk_trk_vecs;
 extern ff_vecs_t ggv_ovl_vecs;
 #if CSVFMTS_ENABLED
 extern ff_vecs_t jtr_vecs;
@@ -864,6 +865,12 @@
  "Navitel binary track (.bin)",
  "bin"
  },
+ {
+ &fugawitrk_trk_vecs,
+ "fugawi_trk",
+ "Fugawi binary track (.trk)",
+ "trk"
+ },
         {
                 &ggv_ovl_vecs,
                 "ggv_ovl",

/*

    Support for Fugawi binary tracks (.trk),
    copyright (C) 2009 jdi@....
    based on navitel.c

    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 <ctype.h>
#include "defs.h"
#include "gbfile.h"
#include "jeeps/gpsmath.h"

#define MYNAME "fugawitrk"

static gbfile *fin, *fout;
static char new_track;
static int trkpts=0;

/*******************************************************************************
* %%%        global callbacks called by gpsbabel main process              %%% *
*******************************************************************************/

static void
fugawitrk_rd_init(const char *fname)
{
        fin = gbfopen(fname, "rb", MYNAME);
}

static void
fugawitrk_rd_deinit(void)
{
        gbfclose(fin);
}

static void
fugawitrk_read_track(void)
{
        route_head *trk = NULL;
        char sig[7];
        int records = 0;
        if (!gbfgets(sig,7,fin))
                fatal("No Fugawi file or file short\n");
        if (strncmp(sig,"FUGTRK",6)) {
                sig[6] = 0;
                fatal("Invalid signature %s\n", sig);
        }
        gbfseek(fin,12, SEEK_SET);
        records = gbfgetuint16(fin); // ??
        warning("%d records\n",records);
        gbfseek(fin,36, SEEK_SET);

        while(!gbfeof(fin)) {
                double lat,lon;
                float alt,distance,heading;
                waypoint *wpt;
                //warning("%d %d\n",i++,gbftell(fin));
                gbfgetint32(fin); // unknwon
                alt = gbfgetflt(fin);
                distance = gbfgetflt(fin);
                gbfgetint32(fin); // unknwon
                heading = gbfgetflt(fin);
                gbfgetint32(fin); // unknwon
                lat = gbfgetdbl(fin);
                lon = gbfgetdbl(fin);
                gbfgetint32(fin); // unknwon
                gbfgetint32(fin); // unknwon

                wpt = waypt_new();
                wpt->latitude = lat;
                wpt->longitude = lon;
                wpt->altitude = alt;
                wpt->course = heading;

                if (trk == NULL) {
                        trk = route_head_alloc();
                        track_add_head(trk);
                }
                track_add_wpt(trk, wpt);
        }
}

static void
fugawitrk_wr_init(const char *fname)
{
        fout = gbfopen(fname, "wb", MYNAME);
}

static void
fugawitrk_wr_deinit(void)
{
        gbfclose(fout);
}

static void
fugawitrk_enum_trkpts(const waypoint *wpt)
{
        trkpts++;
}

static void
fugawitrk_disp_trk_head(const route_head *trk)
{
        new_track = 1;
}
static void
fugawitrk_disp_trkpts(const waypoint *wpt)
{
        if (!trkpts)
                gbfputint16(0x0001, fout); // first point has a 1 here
        else
                gbfputint16(0, fout); // unknwon
        gbfputint16(0, fout); // unknwon
        gbfputflt(wpt->altitude, fout);
        gbfputflt(0, fout); // distance
        gbfputint32(0, fout); // unknwon
        gbfputflt(wpt->course, fout);
        gbfputint32(0, fout); // unknwon
        gbfputdbl(wpt->latitude, fout);
        gbfputdbl(wpt->longitude, fout);
        gbfputint32(0, fout); // unknwon
        gbfputint32(0, fout); // unknwon
        trkpts++;
}


static void
fugawitrk_write_track(void)
{
        char header[36];
        trkpts = 0;
        track_disp_all(NULL, NULL, fugawitrk_enum_trkpts);
        /* TODO
        if (trkpts > 10000) {
                trkpts = 10000;
                warning(MYNAME ": Can store only 10000 points per file!\n");
        }
        */
        memset(header, 0, 36);
        gbfwrite(header,36,1,fout);
        gbfseek(fout, 0, SEEK_SET);
        gbfwrite("FUGTRK", 6, 1, fout);
        gbfputc(0xff, fout);
        gbfputc(0xff, fout);
        gbfputuint16(0x0024, fout);
        gbfputuint16(0, fout);
        //gbfseek(fout, 12, SEEK_SET);
        gbfputuint16(trkpts,fout);
        gbfputuint16(0,fout);
        gbfputuint16(0x0001,fout);
        gbfputuint16(0,fout);
        gbfputuint16(0x0002,fout);
        gbfputuint16(0x0004,fout);
        gbfputuint16(0,fout);
        gbfputuint16(0x00ff,fout);
        gbfputuint16(0,fout);
        gbfputuint16(0x00ff,fout);

        // after header
        gbfseek(fout, 36, SEEK_SET);
        trkpts = 0;
        track_disp_all(fugawitrk_disp_trk_head, NULL, fugawitrk_disp_trkpts);
}

/**************************************************************************/

ff_vecs_t fugawitrk_trk_vecs = {
        ff_type_file,
        {
                ff_cap_none /* waypoints */,
          ff_cap_read | ff_cap_write /* tracks */,
          ff_cap_none /* routes */
        },
        fugawitrk_rd_init,
        fugawitrk_wr_init,
        fugawitrk_rd_deinit,
        fugawitrk_wr_deinit,
        fugawitrk_read_track,
        fugawitrk_write_track,
        NULL,
        NULL,
        CET_CHARSET_UTF8, 1 /* Nothing to convert */
};

/**************************************************************************/

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gpsbabel-code mailing list  http://www.gpsbabel.org
Gpsbabel-code@...
https://lists.sourceforge.net/lists/listinfo/gpsbabel-code

Re: Fugawi Binary trk format

by Robert Lipe-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



On Tue, Sep 8, 2009 at 4:25 AM, Jan Dittmer <jdi@...> wrote:
Hi,

I deciphered the binary waypoint trk format used by
Fugawi (http://l4x.org/gps/fugawi_trk.html).
Attached is a patch to add support to gpsbabel.

Please let me know if the patch is ok and what can
be done to get it merged.

I tested it against some own files and some from the
web and import and export seem to just work.

Seems OK at a glance.    Can you offer a few paragraphs of doc (text is fine if you don't do docbook) and test suite entries with a new section in 'testo' and reference files per the six-step program at the top of format_skeleton.c.

Thanx,
RJL

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gpsbabel-code mailing list  http://www.gpsbabel.org
Gpsbabel-code@...
https://lists.sourceforge.net/lists/listinfo/gpsbabel-code

Re: Fugawi Binary trk format

by Robert Lipe-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm checking the status of several pieces of pending work.  Any progress on this submission?

On Tue, Sep 8, 2009 at 11:49 AM, Robert Lipe <robertlipe@...> wrote:


On Tue, Sep 8, 2009 at 4:25 AM, Jan Dittmer <jdi@...> wrote:
Hi,

I deciphered the binary waypoint trk format used by
Fugawi (http://l4x.org/gps/fugawi_trk.html).
Attached is a patch to add support to gpsbabel.

Please let me know if the patch is ok and what can
be done to get it merged.

I tested it against some own files and some from the
web and import and export seem to just work.

Seems OK at a glance.    Can you offer a few paragraphs of doc (text is fine if you don't do docbook) and test suite entries with a new section in 'testo' and reference files per the six-step program at the top of format_skeleton.c.

Thanx,
RJL


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Gpsbabel-code mailing list  http://www.gpsbabel.org
Gpsbabel-code@...
https://lists.sourceforge.net/lists/listinfo/gpsbabel-code