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

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:
get xml file of selected map
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
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

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.

Related

Use map data offline with osmdroid

My ultimate goal is to have map data (offline, because I will customize it myself) and display it in an app (Android). I could make osmdroid work to load maps online and I was trying to figure out how to download and display offline maps. I downloaded MOBAC (Mobile Atlas Creator) and export the data to SQLite format and when I had a look at it I realized that tiles are saved in image format (PNG).
What I would like to do is to import data to the phone to later use it in algorithms such as a search engine or a routing algorithm, so I need the "nodes" and "ways" (as I get them from the original OSM XML), import them to the phone and visualize it to later have this data available for the algorithms I want to develop. Basically, what MAPS.ME does. I think it wouldn't be difficult to convert the XML into the SQLite since a simple script could make it, but then, how can I generate the tiles from this custom SQLite database? Or, is there a way I can download the data in a more appropriate way to do what I'm planning to do?
Thanks.
Rendering the tiles in an app from raw Openstreetmap data would be computation heavy and inefficient. I would suggest to use image tiles you exported for visual representation.
In addition to tiles you should export a data set you will need in the application for desired functionality. You will not need all data from Openstreetmap so you should identify what you need and build your custom export (there are tools and libraries for processing and filtering of Openstreetmap data. I have used pyosmium for some filtering and processing but there are others.) For example, you can build your custom database with POIs you want to search for.
Routing is another chapter. You can implement it yourself but it is a very complex task. There is java library called Graphopper which can do the data extraction (from Openstreetmap) and offline routing for you. They have an online API too but it is possible to make it working completely offline (I did it for one application). Try to look at the source code because than you can see how complex topic routing is. Final note: data exported from Graphopper contains information about some POIs along routes. It may be possible to search for some things via its java API but I haven't investigated this yet.

route-me together with libosmscout (offline vector maps for iOS)

I´m trying to use the route-me framework together with C++ library libosmscout.
What I have done so far:
import OSM data into libosmscout format
compiling the iOS example-project from libosmscout-repo
The example project only draws one image of the map depending on given lat, long and zoom-factor.
What I want to do is, using the map view functionality of route-me but with map source data from libosmscout.
Is there anybody who has been managed this problem or could give me some hints?
I'm trying to do exactly the same thing.
But I haven' been able to compile the libosmscout for iOS up to now.
Anyway, I'm no sure how comfortable you are with route-me but I'm gonna try and answer your question.
If you are going to use libosmscout to leverage map data form osm xml or pbf files (probably for offline use) you're gonna need to implement a new MapSource and write the code yourself.
you'd better inherit from RMAbstractWebMapSource and implement imageForTile:tile inCache:tileCache method to meet your requirements. Route-me is a tile based map viewer, therefore you need to convert those vector data to tiles, for that you're gonna need to convert tile requests to boundingbox (a few examples are available in OSM wiki) and then try and extract the data from your OSM file and pass it to route-me as an image instance (a png for example).
Don't forget that Route-me caches loaded images, so you have to consider passing the right image for future uses. don't be fooled with the fact that your data is on device, reading vector files can be as demanding as reading raster files from web.

programmatically feed a kml-file and retrieve/generate a .png-file

How can I, programmatically, draw a KML-file (routing information on a map) onto a map and then save the result to a .png-file?
What I try to accomplish: a program of mine (written in C++) produces a route. Now I would like this program to emit a .png-file instead with the route draw on it.
I've looked into the google maps api as well as others (e.g. cartagen) but google maps is java-script oriented and cartagen produces html5 output.
Probably you can use Qt Framework to achive this.
It has great XML support so it should be easy to read KML.
It has support for drawing simple shapes.
It has support for PNGs too.
There is also library called libkml - it can probably help you with manipulating with KML files.
I highly doubt if there is any "Ready to Use" solution.

Recommended file formats and graphics libraries for importing 3D model into OpenGL/C++ project?

If you wanted to:
model an object in a 3D editor, e.g. Blender, Maya, etc
export the model into a data/file format
import the model into an project using OpenGL and C/C++
Then:
What file format would you recommend exporting to, i.e. in terms of simplicity, portability, and compatibility (i.e. common/popular)?
What graphics libraries would you recommend using to import the model into your OpenGL C/C++ project (i.e. preferably open source)?
Additionally, are there data/file formats that also capture animation, i.e. an "animated model" format, such that the animation could be modeled in the 3D editor and somehow invoked inside the code (e.g. accessibility to frames in the animation sequence or some other paradigm for saving/loading details related to changes over time)?
Generally speaking, I'm seeking simplicity as the priority, i.e. help to get started with combining my backgrounds in both art and computer science. I am a computer science major at UMass while at the same time, sort of a "pseudo" double-major in art by taking electives in graphic design at my university as well as classes at the Art Institute of Boston during summer/winter sessions So, in other words, I am not a complete newbie, but at the same time I don't really want options that are so overloaded with crazy advanced configurations making it too difficult to get started with a basic demonstration project; i.e. as a first step to understanding how to bridge the gap between these two worlds, e.g. creating a program featuring a 3D character that the user can interact with.
COLLADA (I'm saying it with a "ah" at the end), and Assimp (ple as that).
And so, why COLLADA? Simple:
COLLADA is an open standard made by Khronos (Sony specifically). The beauty of an open standard format is that it's, well, a standard! You can be assured that any output of a standard-conformant product would also read correctly by another standard-conformant product. Sad to say though, some 3d modelling products aren't that particular in their measures for standards conformance for COLLADA. But still be rest assured: Blender, Maya, 3ds Max and all the other big names in 3d modelling has good support for the format.
COLLADA uses XML. This makes it much more simpler for you if your planning to create your own reader or writer.
ADDITIONAL: COLLADA is, I think, the only format that is not tied to a specific company. This is a very good thing for us, you know.
ADDITIONAL 2: It is known that COLLADA is slow to be parsed. That's true. But think of it: all other non-binary formats (like fbx) have also the same issues. For your needs, COLLADA should suffice.
ADDITIONAL 3: COLLADA supports animations!
For the importer library, I highly recommend Assimp. Why?
Assimp has support for any popular format you can imagine. It has a unified interface for all formats so that switching to another format is less of a pain.
Assimp is extensible. You can thus import your proprietary format and still not modify your code.
ADDITIONAL 4: Assimp is open source! Let's support open source software!
First , here you can read about suggested model loading lbs.Lib Assimp is really good and supports many formats.For the preferred formats.Collada-I wouldn't recommend because that is XML (text) based formats which is slow to parse. Obj format is also widespread but suffers from the same problems as Collada.It is still good if you want to write your own parser as its structure is very simple.But Instead I would suggest 3Ds which is binary.It doesn't support animations though.The most popular format today which supports both static mesh and animation is FBX.You can download for free FBX SDK from Autodesk and connect it to your engine.The reason I would choose FBX is because both SDK and the format are really robust.For example ,in FBX you can embed not just geometry and animation but also scene objects as lights ,cameras etc.Autodesk docs are very nice too.
Hope it helps.
I would reccomend using your own custom format that basically just a binary dump of the vertex buffer and index buffers used in your program. (Using d3d terms there, I know opengl has the same concepts but can't remember if they have different names).
I would then write a separate program using assimp that takes pretty much any format and writes out the file in your custom format. Then you can use collada or whatver to store your actual models in, but not have the complixity and slowness of loading that format at run time.

Java library to create and dynamically modify business diagrams

I am looking for a good java library to manipulate box, arrows and labels in order to dynamically create and fill diagrams like the following and render them to a png :
Another example
I can create a static template to be filled later, but I will need to dynamically create labels for every box and edges in the diagrams.
For now I have tried using batik to manipulate an svg template but creating multiline labels for the edges is proving quite complicated. The SVG way with batik seems to force me to create 1 text object for each label line with absolute positioning for each which is a real pain.
I would like to be able to define the label specifying only the text and the link they relate to, eventually some hints as to how it should be placed and let the library place them.
Any suggestions ?
If this is in a commercial scenario, the Java graph drawing library yFiles can be a good match for your requirements:
You can use a convenient API to create and style your diagram and automatically layout the diagram with lots and lots options to constrain the resulting layout to suit your needs.
Multi-line and (simple) HTML labels are supported out-of-the-box.
Also you can export to PNG (as well as other pixel based image formats) and vector graphics formats like SVG, PDF, EPS.
This can be done both in a regular Java (Swing) application as well as in a headless environment (e.g. to create images on a server and to send them to a web-based thin client dynamically).
To get a feel what can be done using that library, I suggest you take a look at the freely available graph editor application "yEd" that is based on yFiles and lets you try out the above steps in an interactive manner.
(Disclosure: I work for yWorks, but on Stackoverflow I do not represent my employer.)