#!/usr/bin/perl -w # Copywrite Lincoln W. Kliman, www.jbadger.org 2002 # usage: # geo2WindowsXPbat.pl geocaching.loc > geocaching.bat # ./geocaching.bat use strict; #use XML::Filter::Sort; #use XML::SAX::Machines qw( :all ); use XML::DOM; use POSIX; #use PDL::Math; my $file = $ARGV[0]; my $parser = XML::DOM::Parser->new(); my $doc = $parser->parsefile($file); # # From the file gpstrans-0.39/src/gps/sendgpsinfo.c getFileData (...) # Line must start with the word "Format:" (with the colon). # Column offset 8 -- must be the data format (DDD) # Column offset 25 -- time offset read with %lf # Column offset 43 -- must be the 3 digit datum type, read with %3hd, 100 for WGS 84 # # 012345678901234567890123456789012345678901234567890123 #print "Format: DDD UTC Offset: 0.00 hrs Datum[100]: WGS 84\n"; print "\@echo off\n"; #{ TYPE = 0, NAME, COMMENT, DATE, LAT, LON }; # each waypoint is a tab seperated record. # 0 - The line startes with "W" # 1 - The next 6 characters are the waypoint name # 2 - A comment, it is sent last -- used in eTrex as evevation (40 # characters) # 3 - 19 character date. mm/dd/yyyy hh:mm:ss # 4 - latitude # 5 - longitude # # Note I addded a couple of extra tabs at the end. gpstrans does not # bound check to see if it is reading past the end of the line. # # # Wnamecommentmm/dd/yyyy hh:mm:sslatlog my $count = 0; foreach my $waypoint ($doc->getElementsByTagName('waypoint')){ # print "W\t"; # print $waypoint->getElementsByTagName('name') -> item(0) -> getAttribute('id'); # print "\t0 meters\t12/31/1989 01:01:01\t"; # printf "%.7f", $waypoint->getElementsByTagName('coord')->item(0)-> getAttribute('lat'); # print "\t" ; # printf "%.7f", $waypoint->getElementsByTagName('coord')->item(0)-> getAttribute('lon'); # print "opera -remote OpenURL("; $count++; if ($count > 10){ $count = 0; print "pause\n"; } print "rem ", floor( $waypoint->getElementsByTagName('coord')->item(0)-> getAttribute('lat')), "\t"; print " ", $waypoint->getElementsByTagName('name') -> item(0) -> getAttribute('id'), "\n"; print "start /b rundll32 MSHTML.DLL,PrintHTML \""; print $waypoint->getElementsByTagName('link')-> item(0) -> getFirstChild->getNodeValue; print "&pf=y&log=n&decrypt= \n"; # print "new-window )\n"; }