Search code examples
openglmapsgeocodingopenstreetmap

I want to use openStreetMap data to render roads in openGL, where should I start?


What I have in mind is that user will select the part of world he/she wants to generate roads and retrieve openStreetMap data and use it to render roads in openGL.

On searching the web and experimenting, I thought of this approach:

  1. get xml file of selected map
  2. parse the xml and generate roads by openGL.

But I think this is very naive approach.

Also to experiment a bit I used OSM2WorldViewer to convert the xml file to obj file and imported that as a model in openGL, but this method is cumbersome and takes time

the screenshot

and I am unfamiliar with OpenStreetMap api and how it can be used in such a project. Any suggestions, or helpful links how to start this project ?

EDIT: How it ended: Link to the project wiki


Solution

  • Why do you think your approach is naive? Either you have the user to provide a self-downloaded XML file or you have to use an API to retrieve one yourself. The latter approach allows you to implement an automatic update mechanism whenever the user pans the map.

    Instead of the main API you can use the Overpass API for downloading data. It's faster and more flexible to use, allowing to specify which element types to download (e.g. only roads and buildings) and much more.

    You already mentioned OSM2World, take a look at its freely available code to see an example implementation of a 3D OpenGL renderer. Or take a look at one of the other 3D renderers for OSM.