#!/usr/bin/perl -w # Make a PCX5-compatible .rte file # # A good way to get the raw data for this is to use the Maps On US # route planner at http://MapsOnUs.switchboard.com and after the # turn-by-turn output is complete, capture the url for your "Raw # route" data and feed it to # lynx -dump -dont_wrap_pre | mkrte.pl > foo.rte # You'll probably want to wrap a script around that.... # # Good doco of pcx5 seems to be pretty lacking (one pdf from Garmin # that conflicts with what MapSource will import), so more information # format would help. And, of course, this is my first ever attempt # at anything in perl, with all the provisions that go along with # that. format W_REC = W @<<<<< @<<<<<<<<< @<<<<<<<<< @<<<<<<<< @<<<<<<< @<<<< @<<<<<<<<<<<<<<<<<<< $IDNT, $LAT, $LON, $DATE, $TIME, $ALT, $W_DESC . # Skip everything prior to the FORMAT-TYPE line so we don't # get confused about any of the descriptive text that may be # in the dump from lynx. do { $line = ; $_ = $line; } until /FORMAT-TYPE 1\n/; # Write out our starting records now $ROUTE_DESC = "Sample Route"; $RT = 0; $R_DESC = uc $ROUTE_DESC; $R_DESC .= " " x (20 -(length $R_DESC )); $R_REC = "R "; $R_REC .= $RT; $R_REC .= " "; $R_REC .= $R_DESC; $R_REC .= "\n"; print $R_REC; print "H IDNT LATITUDE LONGITUDE DATE TIME ALT DESCRIPTION \n"; # We're into the actual route now. Let's process it! $pt = 0; $DATE = '01-JAN-00'; $TIME = '12:00:00'; $ALT = '-9999'; do { $line = ; $_ = $line; if (/^\s*START /) { # Do first record stuff $pt += 1; $IDNT = "PT" . $pt; @fields = split(/ +/, $line); $LON = $fields[2]; if ($LON gt 0) { $LON = "E" . $LON; } else { $LON = "W" . abs($LON); } $LAT = $fields[3]; if ($LAT gt 0) { $LAT = "N" . $LAT; } else { $LAT = "S" . $LAT; } $W_DESC = 'START'; $~ = "W_REC"; write; }; if (/^\s*TURN /) { # Do intermediate point stuff $pt += 1; $IDNT = "PT" . $pt; @fields = split(/ +/,$line); $LON = $fields[3]; if ($LON gt 0) { $LON = "E" . $LON; } else { $LON = "W" . abs($LON); } $LAT = $fields[4]; if ($LAT gt 0) { $LAT = "N" . $LAT; } else { $LAT = "S" . $LAT; } $line = ; $_ = $line; /[0-9]+ (.+)/; $W_DESC = $1; $~ = "W_REC"; write; }; if (/^\s*END /) { # Do end record stuff $pt += 1; $IDNT = "PT" . $pt; @fields = split(/ +/, $line); $LON = $fields[2]; if ($LON gt 0) { $LON = "E" . $LON; } else { $LON = "W" . abs($LON); } $LAT = $fields[3]; if ($LAT gt 0) { $LAT = "N" . $LAT; } else { $LAT = "S" . $LAT; } $W_DESC = 'END'; $~ = "W_REC"; write; }; } until $line eq "\n"; #$_ = $foo