More scripts: GPS

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
##Sample Script to demonstrate GPSDBASE class
class GPSDBASE gpsdbase;
numeric lognumber1, lognumber2;
string logpath1$, logpath2$, inputdata$, line$, date$, time$;
class DATETIME datetime;
class GPSDATA data;
#Read and parse from an NMEA log
#Adds the log to the log list
#Parses the point records from the log and adds these to the point record list
logpath1$ = _context.ScriptDir + "\test.gps";
lognumber1 = gpsdbase.ReadLog(logpath1$);
#Add log of different format (non-NMEA or MicroImages)
#This will only add the filepath to the loglist
#Does not add the point records
logpath2$ = _context.ScriptDir + "\test2.gps";
lognumber2 = gpsdbase.AddLogPath(logpath2$);
#Add points to log2
#After a LogPath is added using AddLogPath,
#add point records using its lognumber
#For non-standard formats, a full implementation would need to include a function to parse the log
#and get the record's datetime/position data
#Set the point record's datetime
datetime.SetTime(12, 49, 52);
#Set the point record's position
data.Position.x = 139.80748; data.Position.y = 35.71718; data.Position.z = 10;
#Add the record
gpsdbase.AddPoint(lognumber2, datetime, data);
#Add other records...
datetime.SetTime(12, 50, 02);
data.Position.x = 139.80741; data.Position.y = 35.71712; data.Position.z = 10;
gpsdbase.AddPoint(lognumber2, datetime, data);
#Set an Offset if the camera time is different than log time
# (in seconds)
#gpsdbase.SetOffset(-6 * 3600); #-6 hour offset
#Data to get the location for:
#This can be any data with a datetime (digital photo time using EXIF class, etc.)
inputdata$ = _context.ScriptDir + "\Observations.txt";
class FILE datafile;
datafile = fopen(inputdata$); # open text database file
line$ = fgetline$(datafile); # get first line of database file, contains field info
#Could be used to set up fields in a table
while (!feof(datafile)) # while not reached end of file
	line$ = fgetline$(datafile); # get next line in file;
	date$ = GetToken(line$, ",", 2); # parse date entry of line
	date$ = date$.substr(1, date$.length - 2); #remove quotes
	datetime.SetDate(StrToNum(GetToken(date$, "/", 3)), StrToNum(GetToken(date$, "/", 1)), StrToNum(GetToken(date$, "/", 2)));
	time$ = GetToken(line$, ",", 3);
	time$ = time$.substr(1, time$.length - 2);
	datetime.SetTime(StrToNum(GetToken(time$, ":", 1)), StrToNum(GetToken(time$, ":", 2)), StrToNum(GetToken(time$, ":", 3)));
	#datetime for data to find location for
	#GPSDATA returned with position, etc.
	#Interpolate/Closest method of finding
	#Error time in seconds (allowable difference in time between data and log record)
	gpsdbase.Compute(datetime, data, "Interpolate", 60);
	print(date$, time$, data.Position.x, data.Position.y, data.Position.z);