Results 1 to 13 of 13

Thread: [RESOLVED] Reading .ov2 (TomTom files)

  1. #1

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Resolved [RESOLVED] Reading .ov2 (TomTom files)

    Hi,

    I've found an .ov2 parser, but it has been abandoned by the developer a few years ago. Can't find him unfortunately. Tried to convert it to VB.NET without any luck. Perhaps there's a way without the dll, but....

    I can't get it to work and was wondering if someone here knows.

    Code:
    ReadOV2(Application.StartupPath & "\test.ov2")
    Error 1 Reference to a non-shared member requires an object reference. (Readov2)
    Imported everything, but no luck here.

    Can't attach the dll, so I included the source:
    Last edited by Radjesh Klauke; May 15th, 2012 at 03:03 PM.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  2. #2

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Reading .ov2 (TomTom files)

    #removed#
    Last edited by Radjesh Klauke; May 15th, 2012 at 09:28 AM.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  3. #3

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Reading .ov2 (TomTom files)

    #removed#


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  4. #4
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Reading .ov2 (TomTom files)

    Here's a conversion to vb.net that I did. There aren't any compile errors but I don't really have any data to test it against.
    Attached Files Attached Files
    This pattern in common to all great programmers I know: they're not experts in something as much as experts in becoming experts in something.

    The best programming advice I ever got was to spend my entire career becoming educable. And I suggest you do the same.

  5. #5

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Reading .ov2 (TomTom files)

    Will test it 2morrow m8 and see if it works. If you want to I can send you the ov2 I'm using.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  6. #6

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Reading .ov2 (TomTom files)

    Thanks m8. Will have a look at it 2morrow. I believe my flue is getting back at me. Headache is starting. Time for bed. I've attached an ov2 for you.
    Attached Files Attached Files


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  7. #7

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Reading .ov2 (TomTom files)

    Ola Matt,

    1) created a new ClassLib;
    2) imported your classes;

    The following Errors Occur:

    Error 1 'ReadOnly' variable cannot be the target of an assignment. Line 19 col 13 OV2Parser
    Error 2 Option Strict On disallows implicit conversions from 'Long' to 'Integer'. Line 49 col 48 OV2Parser
    Error 3 Overload resolution failed because no accessible 'Read' can be called with these arguments:
    'Public Overridable Function Read(buffer() As Byte, index As Integer, count As Integer) As Integer': Option Strict On disallows implicit conversions from 'Long' to 'Integer'.
    'Public Overridable Function Read(buffer() As Char, index As Integer, count As Integer) As Integer': Value of type '1-dimensional array of Byte' cannot be converted to '1-dimensional array of Char' because 'Byte' is not derived from 'Char'.
    'Public Overridable Function Read(buffer() As Char, index As Integer, count As Integer) As Integer': Option Strict On disallows implicit conversions from 'Long' to 'Integer'. Line 50 col 13 OV2Parser
    Warning 4 Function 'SerializeRectangle' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used. Line 301 col 5 OV2Parser
    Warning 5 Function 'SerializeSimplePOI' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used. Line 356 col 5 OV2Parser

    Error 2/3 isn't interesting cause I fixed it easily, but the rest not.
    Code:
    Dim bytesRead As Byte() = New Byte(CInt(br.BaseStream.Length - 1)) {}
    br.Read(bytesRead, 0, CInt(br.BaseStream.Length))
    EDIT: added "Return returnByte" in the 2 functions, no warnings anymore.
    Last edited by Radjesh Klauke; May 16th, 2012 at 03:14 AM.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  8. #8

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Reading .ov2 (TomTom files)

    I remove the "readonly" and compiled it.
    Works great, but I'd really like to to know how to loop through the ov2 to return all the values.
    There are 4 values you can grab from the ov2: Lat/Long/Name/Telephone. I would like to list them something like:
    1 lat, long, name, telephone
    2 lat, long, name, telephone


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  9. #9

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Reading .ov2 (TomTom files)

    Hé Matt. Got some time?

    Trying to loop through the file, but I can't get it correct.
    vb.net Code:
    1. dim filepath as string "C:\test.ov2"
    2. debug.print(readov2(filepath)(1).lat.tostring)
    3. debug.print(readov2(filepath)(1).long.tostring)
    4. debug.print(readov2(filepath)(1).name.tostring)
    5. '  1 = (index as integer) as ov2parser.poi
    How do I loop through the file?
    for each x as integer in ...... ???

    Thanks in advance.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  10. #10
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Reading .ov2 (TomTom files)

    vb.net Code:
    1. Dim filePath As String = "C:\Temp\test.ov2"
    2.         Dim poiList = OV2Parser.ReadOV2(filePath)

    From there you can loop through the List(Of POI) and get your values.

    vb.net Code:
    1. For i = 0 To poiList.Count - 1
    2.             Console.WriteLine(String.Format("{0} {1}", i, poiList(i).ToString()))
    3.         Next

    And there are 5 values you can get for each point of interest Lat/Long/Name/Telephone/ExtendedData.

    I would recommend overriding the ToString method of the POI class to make it easy for you.

    vb.net Code:
    1. Public Class POI
    2.     Public Property Name As String
    3.     Public Property ExtendedData As String
    4.     Public Property Lat As Double
    5.     Public Property [Long] As Double
    6.     Public Property Telephone As String
    7.  
    8.     Public Overrides Function ToString() As String
    9.         If Me.ExtendedData IsNot Nothing Then
    10.             Return String.Format("{0}, {1}, {2}, {3}, {4}", Lat.ToString(), [Long].ToString(), Name, Telephone, ExtendedData)
    11.         Else
    12.             Return String.Format("{0}, {1}, {2}, {3}", Lat.ToString(), [Long].ToString(), Name, Telephone)
    13.         End If
    14.     End Function
    15. End Class

    Edit: & oops on the Option Strict errors. Switched to VS11 and hadn't changed the setting yet.
    Last edited by MattP; May 17th, 2012 at 09:09 AM.
    This pattern in common to all great programmers I know: they're not experts in something as much as experts in becoming experts in something.

    The best programming advice I ever got was to spend my entire career becoming educable. And I suggest you do the same.

  11. #11

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Reading .ov2 (TomTom files)

    Ola Matt,

    Thanks, but somehow I don't get it. (can't find the lightswitch)

    vb.net Code:
    1. Dim poiList As List(Of OV2Parser.POI) = ReadOV2(filepath)
    2. For each x as integer in .... (poiList not working)


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

  12. #12
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Reading .ov2 (TomTom files)

    Here's POI.vb with the changes to ToString().

    vb.net Code:
    1. Public Class POI
    2.     Public Property Name As String
    3.     Public Property ExtendedData As String
    4.     Public Property Lat As Double
    5.     Public Property [Long] As Double
    6.     Public Property Telephone As String
    7.  
    8.     Public Overrides Function ToString() As String
    9.         If Me.ExtendedData IsNot Nothing Then
    10.             Return String.Format("{0}, {1}, {2}, {3}, {4}", Lat.ToString(), [Long].ToString(), Name, Telephone, ExtendedData)
    11.         Else
    12.             Return String.Format("{0}, {1}, {2}, {3}", Lat.ToString(), [Long].ToString(), Name, Telephone)
    13.         End If
    14.     End Function
    15. End Class

    Here's my code to get the List(Of POI) and iterate through it. From your code it looks like you missed that ReadOV2 is a shared method.

    vb.net Code:
    1. Public Class Form1
    2.  
    3.     Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    4.         Dim filePath As String = "C:\Temp\test.ov2"
    5.         Dim poiList As List(Of POI) = OV2Parser.ReadOV2(filePath)
    6.  
    7.         For i = 0 To poiList.Count - 1
    8.             Console.WriteLine(String.Format("{0} {1}", i, poiList(i).ToString()))
    9.         Next
    10.     End Sub
    11.  
    12. End Class
    This pattern in common to all great programmers I know: they're not experts in something as much as experts in becoming experts in something.

    The best programming advice I ever got was to spend my entire career becoming educable. And I suggest you do the same.

  13. #13

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Re: Reading .ov2 (TomTom files)

    Thanks m8. The modification wasn't needed for my case, but it works like a charm.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width