It is currently September 9th, 2010, 10:01 am

All times are UTC - 5 hours [ DST ]


Shop Camping.com



Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Possible approach to internal waypoint / geocache database
PostPosted: January 6th, 2009, 7:02 pm 
Offline
Compass user

Joined: December 14th, 2008, 6:41 pm
Posts: 97
Location: Germany
GPS: Triton 1500, Oregon 300, some PDAs
Geocaching name: Black-Jack-Team
I found out that the internal database of the Tritons work with SQlite
http://en.wikipedia.org/wiki/SQLite

The internal database resides in the HDD\user folder in different
files.
On my Triton 1500 there are the files:

uds.bin
User1.uds.vol
User1.uds
User1.uds.meta
User1.uds.TrackPoint.dat
TotalMedia.version
TotalMedia.db

With the Firefox-Browser and the SQlite-Manager Plugin
https://addons.mozilla.org/de/firefox/addon/5817
i got a look into the files that i copied prior to the SD-Card with the Triton 1500 Totalmod-Hack out of this forum.

I could open:
User1.uds with all waypoints and geocaches
and
Totalmedia.db with all pictures (and videos?) from the SD-Card

I think a programmer could analyse that in deep and give us a possibilty to get an alternative to Vantage Point regarding the building of a waypoint and geocache database for the Tritons with SD-Card-Slot. One could then build up that database via a SD-Card-Writer from a PC or MAC and then overwrite to the internal HDD\user -folder via a Start-Mortscript on the SD-Card using the Triton-Mod-Hack.

The SQlite-Database-Engine used by Magellan in the Tritons and Vantage Point is available in public domain source code.
Bindings for different programming languages as there are:
(from wikipedia)
SQLite also has bindings for a large number of programming languages, including BASIC, C, C++, Common Lisp, Java, C#, Delphi, Curl, Lua, Tcl, R, PHP, Perl, Ruby, Objective-C (on Mac OS X), Python, newLisp, OCaml, Smalltalk and Scheme. There is also a COM (ActiveX) wrapper making SQLite accessible on Windows to scripted languages such as Javascript and VBScript. This adds database capabilities to HTML Applications (HTA)

Is that a new hope for us?


Top
 Profile  
 
 Post subject: Re: Possible approach to internal waypoint / geocache database
PostPosted: January 7th, 2009, 10:56 am 
Offline
Paper map user
User avatar

Joined: January 23rd, 2008, 6:28 am
Posts: 41
Location: GERMANY, Lower Saxony
GPS: Meridian, eX500, XL, XO, T400/T500/T2000
Geocaching name: inkognito
:mrgreen: :mrgreen: :mrgreen: a new version of "waypointer" that supports reading and writing TritonUDS is already in beta state and will be released within the next weeks.

Gruss, Matz

_________________
waypointer website: http://www.codepointer.de


Top
 Profile  
 
 Post subject: Re: Possible approach to internal waypoint / geocache database
PostPosted: January 7th, 2009, 11:46 am 
Offline
Site Admin
User avatar

Joined: December 5th, 2007, 12:58 am
Posts: 2016
Location: Albany Ny
GPS: Triton 400/2000 - Explorist 500
Geocaching name: Miniwhip
Oooh.... Please keep us posted! =D>

_________________
Your computer is fine, please upgrade to USER v2.0


Top
 Profile  
 
 Post subject: Re: Possible approach to internal waypoint / geocache database
PostPosted: March 2nd, 2009, 5:30 pm 
Offline
Compass user

Joined: December 14th, 2008, 6:41 pm
Posts: 97
Location: Germany
GPS: Triton 1500, Oregon 300, some PDAs
Geocaching name: Black-Jack-Team
Miniwhip wrote:
Don't want to be the bearer of bad news, but SD card storage is NOT going to happen this release. Sorry #-o That does NOT however mean it's not in the cards for the near future.


inkognito wrote:
:mrgreen: :mrgreen: :mrgreen: a new version of "waypointer" that supports reading and writing TritonUDS is already in beta state and will be released within the next weeks.

Gruss, Matz


Now would be the right time to release your software, Matz. I hate waiting for the solution by Magellan, if they would do it ever?!


Top
 Profile  
 
 Post subject: RO sqlite database export (incomplete)
PostPosted: July 28th, 2009, 4:40 pm 
Offline
Paper map user

Joined: April 26th, 2009, 6:29 pm
Posts: 7
GPS: Magellan Triton 1500
I wrote several python scrips. 1st reads trails storage. 2nd - waypoints and trails names (for gpx structure filling). Now I working on routes export. I need few databases from geocachers. Who wants to help?

What Magellan guys can tell me about sharing such information?


Top
 Profile  
 
 Post subject: Re: Possible approach to internal waypoint / geocache database
PostPosted: July 28th, 2009, 5:34 pm 
Offline
Uber poster

Joined: January 1st, 2008, 1:34 pm
Posts: 479
Location: Germany
GPS: Sportrak, T2000
Geocaching name: Sockeye
I would not spend to much time on that topic, as I heard rumors Magellan is working on this for the next FW release...

BR
Sockeye

_________________
Free Magellan Maps at: http://www.maps4me.net/index.php?language=en


Top
 Profile  
 
 Post subject: Re: Possible approach to internal waypoint / geocache database
PostPosted: July 29th, 2009, 5:53 am 
Offline
Paper map user

Joined: April 26th, 2009, 6:29 pm
Posts: 7
GPS: Magellan Triton 1500
No problem. It was easy.
I hope Magellan will make all Linux users happy. And i see only one way for this - complete waypoints/tracks/routes/etc management from SD. Export all data from sqlite database to SD and import back from SD. I'll be very surprised if Magellan really realize such thing with current beta firmware.


Top
 Profile  
 
 Post subject: Script to list and add waypoints to Triton database
PostPosted: July 12th, 2010, 10:51 am 
Offline
Compass user

Joined: March 7th, 2009, 4:49 am
Posts: 56
GPS: Triton 500
Well, I don't know if anybody is still interested in this... Recently I have found a web page

http://sites.google.com/a/gpsinfo.org.ua/www/triton1500

with a few Python scripts to dump information (waypoints, tracks and routes) from TFAT\USER\user1.uds file. As was mentioned in previous posts, this file is an SQLite database. Unfortunately, these scripts did not allow to store new waypoints in that data base.

After some research of those scripts and database schema, I could write my own script which can add new waypoints. I don't write in Python, so I wrote it in Perl. To run this script you will need Perl and Perl::DBI installed on your system.

Run this script on the terminal (or in MS DOS prompt) to see usage info.

To add new waypoints I would recommend to copy TFAT\USER\user1.uds to your computer, add needed waypoints, check if everything is OK, and then copy this file back to TFAT\USER folder.

Just for safety, before doing anything with this script, please, copy and save the original user1.uds file in a separate directory on your computer... If something goes wrong and your Triton will not boot properly, copy that original file back to Triton TFAT\USER folder. I'm not sure but that may help...

I tested it on my Triton 500. It works but remeber: NO WARRANTY OF ANY KIND. Use it on your own risk.

P.S. I don't know why but I can not attach file to the message. Trying to do so returns an error: The extension <pl,txt,nothing... whatever> is not allowed. So I have to insert it here as text.


Code:
#!/usr/bin/perl

use strict;
use DBI;
use Math::BigInt;
use encoding 'utf8';

use constant {
        WP_LIST => 0,
        WP_ADD  => 1,
};

my %opcode = (
        WP_LIST,        "List",
        WP_ADD,         "AddWP",
        );

my $todo      = WP_LIST;
my $file      = undef;

my $latitude  = undef;
my $longitude = undef;
my $altitude  = undef;

my $name      = undef;
my $comment   = undef;

my $verbose   = 0;

while (my $arg = shift @ARGV) {
        getoption($arg);
}

defined $file || usage();
stat    $file || die "No such file: $file\n";

my $dbh = DBI->connect("dbi:SQLite:$file") || die "Cannot connect: $DBI::errstr";

vprint ("Operation: $opcode{$todo}, Input file: $file\n");

exit(qlist($name))                                                      if $todo == WP_LIST;
exit(addwp($latitude, $longitude, $altitude, $name, $comment))          if $todo == WP_ADD;


sub getoption {
        $verbose = 1, return                            if $_[0] eq '-v';
        $file = shift @ARGV, return                     if $_[0] eq '-F';
        $todo = WP_ADD, getwp(), return                 if $_[0] eq '-a';
        $todo = WP_LIST, $name = shift @ARGV, return    if $_[0] eq '-l';
        print "Unrecognized option: $_[0]\n";
        usage();
}

sub usage {
print <<EOF;

Usage:

Print waypoints:

        $0 -F <path to DB file>
       
        or
       
        $0 -F <path to DB file> -l
       
        Example:
       
        $0 -F user1.uds -l
       
Search waypoints whose name or comment contains <pattern>:

        $0 -F <path to DB file> -l <pattern>
       
        Example:
       
        $0 -F user1.uds -l wp0001

Add a new waypoint

        $0 -F <path to DB file> -a <latitude> <longitude> <altitude> <name> <comment>
       
        Example:
       
        $0 -F user1.uds -a  48.856667   2.350987  36 Paris
        $0 -F user1.uds -a  51.500152  -0.126236  14 London
        $0 -F user1.uds -a -22.906365 -47.061574 677 Campinas "San Paulo, Brazil"

Names and comments containing space must be quoted (see last example).

To veiw SQL quieries, add option -v, for example:

   $0 -v -F user1.uds -a  48.856667   2.350987  36 Paris
       
        or
       
        $0 -v -F user1.uds -l wp0001

EOF

die "\n";

}

sub getwp {
        $latitude  = checknum(shift @ARGV);
        $longitude = checknum(shift @ARGV);
        $altitude  = checknum(shift @ARGV);
       
        $name    = shift @ARGV;
        $comment = shift @ARGV;
}

sub checknum {
        $_[0] =~ /^[\d\.\-\+]+$/ || die "Not a number: $_[0]\n";
        my $num = sprintf("%11.6f", $_[0]);
        return $num;
}

sub qlist {
        my $search = shift;
        my $sql = "
                SELECT wp.Name,
                       strftime('%Y-%m-%dT%H:%M:%SZ',wp.TimeStamp/10000000 - 11644473600,'unixepoch') AS WPDate,
                       Latitude, Longitude, Altitude, Comment
                       
                       FROM WayPoint wp, GeoPoint gp, GpsFix fx
                       
                       WHERE wp.GPID = gp.rowid + 79691776
                         AND fx.GPID = gp.rowid + 79691776
                         ";
        if (defined $search) {
                $search = $dbh->quote("%$search%");
                $sql .= "AND (wp.name LIKE $search OR wp.Comment LIKE $search)";
        }
        vprint("$sql\n\n");
        my $table = $dbh->selectall_arrayref($sql);
        printf("%-20s %-25s %11s  %11s %7s %s\n", "Name ", "Date and Time (UTC)", "Latitude", "Longitude", "Alt", "Comment");
        foreach my $wp (@$table) {
                my ($name, $datetime, $latitude, $longitude, $altitude, $comment) = @$wp;
                printf("%-20s  %-25s  %11.6f %11.6f %7.0f %s\n", $name, $datetime, $latitude, $longitude, $altitude, $comment);
        }
}

sub addwp {
        my ($latitude, $longitude, $altitude, $name, $comment) = @_;
        $name    = substr($name,0,20);
        $comment = substr($comment,0,60);
        $altitude = sprintf("%d", $altitude);
        vprint ("Data: $latitude, $longitude, $altitude, '$name', '$comment'\n");
        insertwp($latitude, $longitude, $altitude, $name, $comment, "Crossed Square");
}

sub insertwp {

        $dbh->begin_work;
       
        my ($lat, $lon, $alt, $name, $comm, $icon) = @_;
       
        my $timestmp = (time + Math::BigInt->new('11644473600')) * 10000000;
       
        my $gpid = addobj(1003, 'GeoPoint', "Latitude = $lat, Longitude = $lon") | 0x04c00000;
        addobj(1002, 'GpsFix', "GPID = $gpid, Altitude = $alt");
        my $iid = addobj(1009, 'Icons') | 0x05400000;
        my $cid = addobj(1008, 'Category', "Type = 0, IID = $iid") | 0x02c00000;
       
        my $wpname = $dbh->quote($name) . " || x'0000'";
        my $wpcomm = $dbh->quote($comm) . " || x'0000'";
        my $wpicon = $dbh->quote($icon) . " || x'0000'";
       
        my $wpid = addobj(1005, 'WayPoint',
                "GPID = $gpid, CID = $cid, SCID = 4, Name = $wpname,
                 Comment = $wpcomm, Type = 'WP' || x'0000', SymbolName = $wpicon, TimeStamp = $timestmp");
       
        my $roid = getroid('WayPoint', "rowid = $wpid");
       
        addqspell(1005, $wpname, $roid);
        addqspell(1005, $wpcomm, $roid);
       
        $dbh->commit;
}

sub addobj {
        my ($roottype, $table, $setargs) = @_;
        my $timestmp = (time + Math::BigInt->new('11644473600')) * 10000000;
        my $sql = "INSERT INTO Root VALUES($roottype,$timestmp,0,0,0)";
        vprint ($sql, "\n");
        $dbh->do($sql) || $dbh->rollback && die "Can not $sql";
        my $roid = $dbh->last_insert_id(undef, undef, undef, undef) | 0x00400000;
       
        $sql = "INSERT INTO " . $table . "(" . $table . "_ROID) VALUES(" . $roid . ")";
        vprint($sql, "\n");
        $dbh->do($sql) || $dbh->rollback && die "Can not $sql";
        my $rowid = $dbh->last_insert_id(undef, undef, undef, undef);
       
        if (defined $setargs && $setargs ne '') {
                $sql = "UPDATE " . $table . " SET " . $setargs . " WHERE rowid = " . $rowid;
                vprint ($sql, "\n");
                $dbh->do($sql) || $dbh->rollback && die "Can not $sql";
        }
        return $rowid;
}

sub addqspell {
        my ($type, $text, $roid) = @_;
        $text = lc $text;
        my $sql = "INSERT INTO QuickSpell (Value,Ordinal,ROID,Type) VALUES ($text , 4, $roid, $type)";
        vprint ($sql, "\n");
        $dbh->do($sql) || $dbh->rollback && die "Can not $sql";
}

sub getroid {
        my ($table, $where) = @_;
        my $sql = "SELECT $table" . "_ROID FROM $table WHERE $where";
        vprint ($sql, "\n");
        my ($roid) = $dbh->selectrow_array($sql);
       
        defined $roid && $roid ne '' || $dbh->rollback && die "Database error on $sql\n";
        return $roid;
}

sub vprint {
        return if not $verbose;
        while (my $string = shift @_) {
                print $string;
        }
}



Top
 Profile  
 
 Post subject: Re: Possible approach to internal waypoint / geocache database
PostPosted: July 13th, 2010, 9:46 am 
Offline
Paper map user

Joined: April 26th, 2009, 6:29 pm
Posts: 7
GPS: Magellan Triton 1500
Yes. You found my page. :)
Not all files in sqlite format. Tracks in binary.
Nobody asked to store waypoints. And I mostly prefer Ozi/OziCE, so I don't finish import of objects. Because in any way there is no good (for tracking purposes) gps software for linux (I mean Ozi analog).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: MSN [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2007 phpBB Group
xand 2 for phpBB3 by Thomas Hoornstra and Shadow_One