Hi,
no one integrated Open Street Map navigation in Unity project?
Thank you!
Gius
Hi,
no one integrated Open Street Map navigation in Unity project?
Thank you!
Gius
I don’t know what you mean by “Open Street Map navigation”, but Unity has been used a lot for visualisation of OSM data, as a quick Google would reveal… ![]()
EDIT: OK now we have a question, here’s an outline of the work involved.
Download OSM format XML of area you want to map
OSM XML is very bloated/comprehensive, XML parsing is expensive, so you want to filter out the XML nodes you don’t need for your application. For this use the osmfilter command line utlility.
So now the goal is to turn the filtered XML into data structures in C# you want to draw…
A first step is to convert the XML into an XDocument data structure, e.g.
string fnp = "Path/to/your/XML/File.map";
string mapxml;
using (StreamReader streamReader = new StreamReader (fnp, System.Text.Encoding.UTF8))
mapxml = streamReader.ReadToEnd();
if (mapxml == null || mapxml.Equals("")) {
Debug.LogError ("Error reading map XML");
return;
}
xdoc = XDocument.Parse (mapxml);
Now you have the parsed XML in the xdoc variable, you need to parse it to do… whatever you want to do with the data. You will need to learn the OSM XML format. Most roads, rivers, building outlines are organised into polygons or polylines called “ways”.
Ways are mainly defined by Nodes (lat/long coordinates) and tags describing the type of way e.g. road, river, building…
As you are looping over the xdoc you will typically be instantiating classes representing OSM XML constructs, such as buildings, or for road navigation, creating a bi-directional graph representing the road network. Basically this will be a list of lat/long coordintates
Then you will want a method to convert the lat/long into Unity units, and then maybe draw roads using a line renderer, or procedurally generate 2d polygons which are then extruded into meshes. It depends what you want to do.
It is not a project I would recommend for a beginner.