Rendering a 3D-map from an Openstreetmap data can be pretty cumbersome.
But what if the requirements are less demanding than rendering any city of the world in 3D?
What if I just need to render only a certain city limited by particular boundaries? There should not be a lot of polygons to render, especially if I choose to render only those buildings and roads that are actually seen on the screen (I have heard that this technique is used in game development).
I wish to achieve something like this, but it is ok to have just simple boxes for buildings with approximate height and no textures. So, basically I just need an OSM-based road network and simple boxes representing buildings in 3D.
So, the plan could be the following:
- extract OSM data into an .osm file;
- add "height" data to each building in this file (manually);
- render the 3D view of the map from the .osm file (requires a custom parser) with some kind of 3D engine.
Is this plan feasible? Are there any open-source 3D engines that I can use/customize to render an OSM map from an .osm file? Are there any Linux-compatible (OpenGL?) 3D engines exist that can be [possibly] customized to render an OSM map?
You might want to have a look at OSM2World. It's a converter application that reads OSM data in various file formats and calculates 3D models, taking into account height, roof shape and material attributes of buildings as well as various other details. It can either display the scene with its built-in OpenGL viewer or export the models to formats like .pov or .obj, the latter of which can be read by almost all Open Source modelers and engines.
If the buildings in the area are well-mapped, scenes look like this:
There is also an overview of 3D development activities in the OpenStreetMap community, showcasing several other tools.
Here are a few open-source projects that you can adapt to your needs (see below) most are using opengl which should work fine for your needs as well.
I'd look at glosm first. It's doing most of what you want. You can see some screen shots of it here
Be aware that in most areas OpenStreetMap has only on lots and roads and other stuff, but not individual buildings. That was the case last time I checked, but it depends on the area you're interested in.
As far as I know there's no off-the-box way to do this, but if you just want simple things it should not be that complicated. Brief description:
1 -Extract the footprints polygon data from the osm xml file.
2 -Project into a Cartesian of your choice, for example using PROJ.4, since osm coordinates are in lat-long.
3 -Triangulate to avoid non-convex polygons.
4 -Extrude your triangulated polygon generating a quad for each boundary edge.
5 -Finally, you can insert the generated models into your favorite 3d engine for example OpenSceneGraph or render them by yourself using OpenGL.
After that, the more things you want to add like textures, modeled detail, the more it gets complicated.
Many cities have online access to Real Estate records, including building dimensions.