Jump to content

jcsjcs2

Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by jcsjcs2

  1. I know this thread is already quite old, but I came across this problem quite recently with my Oregon 300. This is how I overcame the problem. The Oregon 300 stores all waypoints in internal memory, not accessible from the outside. The only way to remove waypoints is through Oregon's interface, either by deleting them one by one, or by deleting all of them at once in the "System-->Reset" menu. Every time the Oregon switches to mass storage mode, the internal memory is written to Garmin/GPX/Current/Current.gpx. This file contains (at least) waypoints and routes. My first script creates a list of waypoint names from this file which you can edit in any text editor, removing all the waypoints you don't like, leaving only the waypoints you would like to keep. My second script then extracts all waypoints from Current.gpx that are listed in that file. Next reboot your Oregon and remove all waypoints. After all waypoints have been removed, go back to mass storage mode and copy the extracted waypoints to Garmin/GPX/ Upon the next reboot only those waypoints will show up. Please note that these waypoint files will only be read once after you copy them. If you want them to be re-read, for example because you have wiped all waypoints again, you will have to copy them again, or "touch" them to update the timestamp. Before I paste the scripts here some words about why I ended up with so many waypoints. Every time geotaod downloads geocaches for me, it downloads a considerable number of waypoints along with them. The easiest way to avoid this is to use "--format=gpx-gsak" instead of "--format=gpx". This will not download any waypoints that will fill up your waypoint memory. jcs. Script 1. Under Linux call as MakeWayPointList Current.gpx > wp_list.txt The waypoints will be written to wp_list.txt #!/usr/bin/perl -w use strict; use XML::Twig; # Call as # MakeWayPointList.pl <Current.gpx> # or like this to use STDIN # MakeWayPointList.pl # # A list of all waypoint names will be output to STDOUT. # # Note that the Oregon will read waypoint files only once. Therefore, if you delete all waypoints # in the System->Reset menu, they will still be gone even after the next reboot. # To have your waypoint files re-parsed, you'll have to 'touch' them to update the creation date. # Alternatively just copy the files to the Garmin again. #my $twig= new XML::Twig; # twig will be created only for wpt elements my $twig= new XML::Twig (twig_roots => { 'wpt' => 1}, # handler will be called for wpt elements twig_handlers => { 'wpt' => \&wpt_handler } ); if( $ARGV[0]) { $twig->parsefile( $ARGV[0]); } # parse a file else { $twig->parse( \*STDIN); } # parse the standard input sub wpt_handler { my( $twig, $wpt)= @_; print $wpt->first_child('name')->text, "\n"; $twig->purge; } Script 2 Call as ExtractWayPoints.pl Current.gpx wp_list.txt > MyWaypoints_DATE.gpx Your selection of waypoints will be written to MyWaypoints_DATE.gpx #!/usr/bin/perl -w use strict; use XML::Twig; # Call as # ExtractWayPoints.pl <Current.gpx> <wp_list.txt> # or like this to use STDIN # ExtractWayPoints.pl <wp_list.txt> # # Only waypoints listed in wp_list.txt will be output to STDOUT. die unless "$ARGV[0]" ne ""; # twig will be created only for wpt elements my $twig = new XML::Twig (twig_roots => { 'wpt' => 1}, # handler will be called for wpt elements twig_handlers => { 'wpt' => \&wpt_handler }); my %waypoints = (); if( $ARGV[0] && $ARGV[1] ) { # parse a file read_waypoints ($ARGV[1]); $twig->parsefile( $ARGV[0]); } else { # parse the standard input read_waypoints ($ARGV[0]); $twig->parse( \*STDIN); } $twig->print; sub wpt_handler { my( $twig, $wpt) = @_; my $wptname = $wpt->first_child('name')->text; $wpt->cut unless $waypoints{$wptname}; } sub read_waypoints { my $file = shift; open(my $fh, "<", $file) || die "Couldn't open '".$file."' for reading because: ".$!; while(<$fh>) { chomp $_; $waypoints { $_ } = '1'; # add name of waypoint to hash # print $_, "...\n"; } close $fh; }
×
×
  • Create New...