Navigation Performance

Discussion in 'Questions (Windows Mobile)' started by Saj, Jun 18, 2009.

  1. Saj

    Saj Active Member Licensed User


    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
    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

    xStart1=0 'reset to prevent extraneous lines appearing when good signal and moving map with mouse at start/end of route
    End Sub
  2. derez

    derez Expert Licensed User

    It seems like overload of the graphics, try to limit the actual drawing to the area of the screen (the part of the map that is seen on the screen).
  3. klaus

    klaus Expert Licensed User

    Do you have a code example (sbp file) so we could test it and look where the problem does come from ?
    How often and from where do you call the drawTrack routine ?

    frmGPS.FLine(xStart1, yStart1 ,xEnd1, yEnd1, cRed)
    1, yStart1 ,xEnd1+1, yEnd1, cRed)
    What is the 2nd line for ?
    Is it to have thicker line ? If yes you could use the ImageLibEx, there you can define the line thickness.
    In your case, if the line is almost horizontal, there will be no effect.

    Best regards.
  4. Saj

    Saj Active Member Licensed User

    You're right guys, I was trying to do too much drawing on the forelayer. Just drawing parts of the track that will be visible, performance is much better as I have 1 second between position updates.

    Can u confirm if version 1.5 of the ImageLibEx is the latest and do you know if it is any quicker than the FLine method I have been using?

    Many thanks.

    Saj, UK
  5. klaus

    klaus Expert Licensed User

    Yes, the latest version of ImageLibEx is 1.5, you can find the latest libraries and their version number here: ttp://

    I have never made any speed tests between drawing directly onto the form's forelayer or onto the form with a Drawer object or onto a bitmap with a Drawer object and copying the bitmap onto the form background.

    An advatage with the Bitmap is that you can use a bitmap bigger than the screen size and copy the desired part of it onto the form,'s background. But I don't know what would be the influence on speed.

    Best regards.
  6. agraham

    agraham Expert Licensed User

    Any drawing you do ImageLib or ImageLibEx should be faster than a Forms' own drawing methods. This is because the Forms methods repaint the changed area of the Form every time they are used whereas if you use a Drawer to draw on a Form or Bitmap the Form is only redrawn when you use a Refresh method for a Form when you have finished drawing on the Form or have assigned a Bitmap to a Form or Image control.
  7. Saj

    Saj Active Member Licensed User

    The attachment shows an error msg I am getting with the DrawerEx library - "Object Reference Not Set to an Instance of an Object", yet the object exists (SolidBrushEx); see RHS of jpg. Can anyone see what is happening here?:sign0163:
  8. agraham

    agraham Expert Licensed User

    Line 1902 loks OK. It looks like you are trying to draw on a Form's forelayer. Have you enabled that on the Form by "FormName.ForeLayer = True"? As the problem doesn't look like line 1902 itself the problem is elsewhere and you will have to post some source that exhibits it.
  9. Saj

    Saj Active Member Licensed User

    The forelayer is enabled in App_Start. I have noticed that ImageLibEx version 1.5 responds with 1.4 when executing ImageLibEx.DLLversion. Does that shed any light?
  10. agraham

    agraham Expert Licensed User

    No, it's a typo. It is correctly reported as version 1.5 when optimised compiled which you should try as the optimising compiler is pickier than the IDE and may throw up the real source of the error, otherwise you will have to post some source that demonstrates the problem.
  11. Saj

    Saj Active Member Licensed User

    Cut down version of program attached. To see error, right click once, then try to drag the grey screen a couple of times with left hand mouse button.
  12. agraham

    agraham Expert Licensed User

    I don't think that you have tried optimised compiling as I suggestested because the code you posted fails.

    Also End If is a construct in its own right so you don't need all the multiple "End If"s

    If ... Then
    ELse If ... Then
    Else If ... Then
    End If

    Your mix of libraries is puzzling. If you expect this to run on the device there should be a one to one equivalent of device and desktop libraries, either the same on both desktop and device where the library will run on both or a desktop version and the equivalent device version where they need to differ.

    You don't need both ImageLib and ImageLibEx libraries, use one or the other.

    Running and right clicking brings up a an error "Error loading map: MapLeicester.jpg" not the error you described.

    I'm sorry but I don't have time to sort this out. Please post a simplified version that you have tested that actually runs and shows the errror in question.

    EDIT:- However, luckily for you, I noticed that you are initialising the DrawerEx before activating the forelayer on frmGPS. You need to activate the forelayer first or the initialisation of DrawerEx (or Drawer from ImageLib) will not find a forelayer to draw on.
    Last edited: Jul 2, 2009
  13. Saj

    Saj Active Member Licensed User

    Can someone help me understand what the attach error means when optimised compiling for a Device exe.

    Line 2151: s = s & ".Net Version: " & Hard.NetVersion & CRLF

    Attached Files:

  14. derez

    derez Expert Licensed User

    It means that you have not defined Hard as an object of Hardware library.
  15. Saj

    Saj Active Member Licensed User

    Don't know how i missed that one. I'm also getting the attached error with a msgbox when compiling:
  16. klaus

    klaus Expert Licensed User

    It should be:
    you need bracket.

    Best regards
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice