#!/usr/local/bin/perl $cmd = "PMGNWPL,"; # Warranty: none. Use at your own risk # A. Whinery, U. Hawaii ITS, 7/7/99 # # This program was written to ingest record files that were created by # ngsingest.pl, from National Geodetic Survey Data Sheets, like the ones # found at http://www.ngs.noaa.gov/datasheet.html # #TU0417 7 21 17.383 -157 49.166 8.756 HONOLULU (1986) OTHER NAD 83(1986) # # the format of the input file is as above, in plain text with TAB separated # fields: # #1) Marker PID #2) MARKER Designation #3) Marker Latitude #4) MArker Longitude #5) Marker Elevation #6) USGS Quad in which Marker appears #7) Marker Datum (probably always NAD83) # # Note that the Magellan GPS protocol does not appear to make note of DATUM, # and the unit seems to consider any positions put it via the serial connection # to be WGS84, which is really really close to NAD83, if not identical. # # This script will take a file in the format specified above as standard input, #and output a series of records to be sent to the Magellan GPS as standard #output. # $nums ="0123456789ABCDEF"; while(<>) { ($pid,$des,$lat,$lon,$elev,$quad,$mrk,$datum) = split(/ /,$_); ($quad,$garb) = split(/\(/,$quad); $s=""; for ($i =0; $i < (9 - length($quad)); $i++) { $s = $s." "; } $quad = $quad.$s; $lat =~ s/ //g; $lat += .0001; $lat = substr($lat,0,8); $lon =~ s/ //g; if ($lon < 0) {$lon = $lon * -1;} $lon += .0001; $lon = substr($lon,0,9); if (($elev - int($elev)) => .5) { $rup =1;} else {$rup = 0;} $elev += $rup; $s=""; for ($i =0; $i < (7 - length(int($elev))); $i++) { $s = $s."0"; } $elev = $s.int($elev); #$cmd = "PMGNWPL,2121.864,N,15740.230,W,0000271,M,HOME,ALAN HOUSE,a"; $a= $cmd.$lat.",N,".$lon.",W,".$elev.",M,".$pid.",".$mrk.",b"; $b = vec(substr($a,0,1),0,8); for ($i = 1; $i < length($a);$i++) { $b ^= vec(substr($a,$i,1),0,8); } $up = substr($nums,int($b/16),1); $low = substr($nums,$b - $up * 16,1); $b = $up.$low; print "\$",$a,"*",$b,"\n"; }#while