' GPSFixer -- insert current GPS position directly ' into an editable ArcView GIS point theme. Used for collecting ' the location of objects, along with an associated ' table or database. ' ' Author: Bryce Nesbitt, http://www.obviously.com ' Works on: ArcView 3.x Avenue ' Find VTab or FTab object, which contains the database table. ' theDoc = av.GetActiveDoc if(theDoc.is(View)) then for each t in theDoc.GetActiveThemes myFTabVTab = t.GetFTab end elseif(theDoc.is(Table)) then myFTabVTab = theDoc.GetVTab else MsgBox.Info("To insert the current GPS position, select a theme or table, and make it editable. The theme must have fields lat and long. The start_gps.bat helper utility must be running in the background.","GPSFixit") exit end ' Find indexes to each named field ' fShape = myFTabVTab.FindField( "Shape" ) fLat = myFTabVTab.FindField( "Lat" ) fLon = myFTabVTab.FindField( "Long" ) fTime = myFTabVTab.FindField( "Time" ) ' Read GPS location from comma separated file on local disk ' (we depend on an external program to put it there) ' f = "c:/gpsfix.txt".AsFileName gpsFile = LineFile.Make(f, #FILE_PERM_READ) if( gpsFile = NIL ) then MsgBox.Info("c:/gpsfix.txt not found, the start_gps.bat helper utility must be running in the background.","GPSFixit") exit end buf = gpsFile.ReadElt gpsTokens = buf.AsTokens(",") thePoint = gpsTokens.Get(1).trim.AsNumber@gpsTokens.Get(0).trim.AsNumber gpsFile.Close ' Add a new record. This used to allow editing the GPS ' position, but that just led to mistakenly overwriting data. ' rec = myFTabVTab.AddRecord ' Insert GPS fix into table ' myFTabVTab.SetValue( fShape, rec, thePoint ) myFTabVTab.SetValue( fLat, rec, gpsTokens.Get(0).trim.AsNumber ) myFTabVTab.SetValue( fLon, rec, gpsTokens.Get(1).trim.AsNumber ) myFTabVTab.SetValue( fTime, rec, gpsTokens.Get(2).trim.AsNumber )