Search Unity

reading gps data/kml file

Discussion in 'Scripting' started by Krodil, Nov 25, 2011.

  1. Krodil

    Krodil

    Joined:
    Jun 30, 2010
    Posts:
    141
    hey,
    Any tips for reading in a set of gps positions from a kml file or txt file?
    Subsequently I wish to spawn certain objects on the positions given.
    I know there will be some mapping from gps to unity terrain coords.

    Hope you can help,
    Krodil
     
  2. Ted-de-Munnik

    Ted-de-Munnik

    Joined:
    Mar 13, 2011
    Posts:
    119
    How is this txt file formatted?
    If it is one position on a new line, you can use default .NET IO libraries(System.IO) to loop trough every line.

    Then there problably(correct me if i'm wrong) should be some sort of character in between x, y, z. You can split the string by this delimiter to find the x,y, z coordinate and then instantiate a gameobject at that location.

    For the looping you should use this as a reference:
    http://stackoverflow.com/questions/1500194/c-looping-through-lines-of-multiline-string

    Hope this has helped ;)