Hi
I'm trying to a draw a track of my position (every second) as current position moves in my navigation program. Latitude/longitude is stored in a structure array every 5 secs - "Dim Type(lat, lon)trackArr (100)".
As the array fills up, the performance starts to drop off rapidly such that when only 20 array elements (approx.) have been filled with lat/lon the execution of the array (see below) takes up so much time that it misses current position updates and takes ages to repond to key/screen touches.
Can anyone suggest a way around this? Is there a more efficient way of storing and displaying the track?
Sub drawTrack
For i=0 To ArrayLen(trackArr())-1
If trackArr(i).lat = "" Then
'Return - this exits sub
Exit ' jump out of for loop as the tr ck array has no values to plot
End If
'Convert Lat/Lon to screen position, see Notes p62-64 for derivation
ratioX = (trackArr(i).lon - mapLonXmin) /(mapLonXmax - mapLonXmin)
X_pix = Int(ratioX*MapWidth*zoom) +jpgXposn_onScreen0_0
ratioY = (mapLatYmax - trackArr(i).lat) /(mapLatYmax - mapLatYmin)
Y_pix = Int(ratioY*MapHeight*zoom)+ jpgYposn_onScreen0_0
'Draw track line
If xStart1=0 AND yStart1=0 Then
xEnd1 = X_pix
yEnd1 = Y_pix
xStart1 = X_pix+10 'dummy value for initialisation
yStart1 = Y_pix+10 'dummy value for initialisation
Else
xStart1 = xEnd1 'xEnd from previous iteration
yStart1 = yEnd1 'yEnd from previous iteration
xEnd1 = X_pix
yEnd1 = Y_pix
frmGPS.FLine(xStart1, yStart1 ,xEnd1, yEnd1, cRed)
frmGPS.FLine(xStart1+1, yStart1 ,xEnd1+1, yEnd1, cRed)
End If
Next
xStart1=0 'reset to prevent extraneous lines appearing when good signal and moving map with mouse at start/end of route
yStart1=0
xEnd1=0
yEnd1=0
End Sub
I'm trying to a draw a track of my position (every second) as current position moves in my navigation program. Latitude/longitude is stored in a structure array every 5 secs - "Dim Type(lat, lon)trackArr (100)".
As the array fills up, the performance starts to drop off rapidly such that when only 20 array elements (approx.) have been filled with lat/lon the execution of the array (see below) takes up so much time that it misses current position updates and takes ages to repond to key/screen touches.
Can anyone suggest a way around this? Is there a more efficient way of storing and displaying the track?
Sub drawTrack
For i=0 To ArrayLen(trackArr())-1
If trackArr(i).lat = "" Then
'Return - this exits sub
Exit ' jump out of for loop as the tr ck array has no values to plot
End If
'Convert Lat/Lon to screen position, see Notes p62-64 for derivation
ratioX = (trackArr(i).lon - mapLonXmin) /(mapLonXmax - mapLonXmin)
X_pix = Int(ratioX*MapWidth*zoom) +jpgXposn_onScreen0_0
ratioY = (mapLatYmax - trackArr(i).lat) /(mapLatYmax - mapLatYmin)
Y_pix = Int(ratioY*MapHeight*zoom)+ jpgYposn_onScreen0_0
'Draw track line
If xStart1=0 AND yStart1=0 Then
xEnd1 = X_pix
yEnd1 = Y_pix
xStart1 = X_pix+10 'dummy value for initialisation
yStart1 = Y_pix+10 'dummy value for initialisation
Else
xStart1 = xEnd1 'xEnd from previous iteration
yStart1 = yEnd1 'yEnd from previous iteration
xEnd1 = X_pix
yEnd1 = Y_pix
frmGPS.FLine(xStart1, yStart1 ,xEnd1, yEnd1, cRed)
frmGPS.FLine(xStart1+1, yStart1 ,xEnd1+1, yEnd1, cRed)
End If
Next
xStart1=0 'reset to prevent extraneous lines appearing when good signal and moving map with mouse at start/end of route
yStart1=0
xEnd1=0
yEnd1=0
End Sub