[Marble-devel] Using marble to render PostGIS data in different Projections

tackat at t-online.de tackat at t-online.de
Mon Feb 10 11:31:06 UTC 2014


Hi Knut,

I had always wondered why nobody had done this earlier. It should be relatively straightforward. Ideally you would do it differently though: Nowadays the GeoPainter approach is too lowlevel. These days we rather discourage to use GeoPainter directly - although there is nothing bad about GeoPainter itself.These days we rather encourage the "object-oriented" approach. The "object-oriented" approach has lots of  benefits and it should go extremely well with PostGIS: 

Nowadays Marble imports all files into a single data model: No matter  whether it's KML, GPX, SHP (ShapeFiles) or OSM vector data - all files get imported into a single "GeoDataDocument"-document model (we informally call that "The GeoData way" since the related classes have the prefix "GeoData").
The rendering of that model is then done automatically by GeoPainter behind the scenes. So you don't have to mess with GeoPainter directly and you don't have to care about the rendering part! This is an advantage since this is much more convenient for you and also since GeoPainter might get replaced by an OpenGL-based painter/renderer at one point. So if you go "the GeoData way" your code will stay future-proof :-)

For importing the PostGIS data into the model you should probably have a look at the file-import plugins. Yes, each fileformat in Marble is converted to that single data model via a dedicated plugin. Have a look inside the source code here:

src/plugins/runner

In that directory you will find lots of "runners" which create GeoDataDocuments for various purposes. You probably want to have a look at the runners which import the files. Those are inside the subdirectories kml, gpx, shp, osm. My guess is that the SHP-file is probably most close to the PostGIS case. So you can borrow lots of ideas from there. The KML case is also very interesting - especially since the structure of our central universal data-model is inspired by KML. So if you know KML then you will get immediately fluent with the GeoData classes since they are named structured the same way as KML (although they can hold GPX, OSM, SHP and PostGIS data - the challenge is just to map the information correctly). You can probably fully ignore the OSM runner, since the vector OSM fileformat has a pretty "weird" structure.

For learning more about the GeoDataDocument structure you can have a look at these this tutorial:

http://techbase.kde.org/Projects/Marble/Runners/DisplayGeoDataPlacemark

and these:

http://techbase.kde.org/Projects/Marble/Runners/Parse
http://techbase.kde.org/Projects/Marble/Runners/LoadingOSM

So I suggest that you create a "postgis runner" plugin which would act as an interface between the PostGIS database and Marble's GeoDataDocument document model. Oh and yes of course this approach would allow for reversing the whole process. In the future you could allow users to edit polygons inside Marble and have the GeoDataPolygons get written back to the PostGIS database.

So if you look at the (relatively small) file parsing plugins you should see that this should all be doable.
Additional incentive: If you implement this PostGIS runner and contribute it back to Marble then I owe you a beer and a pizza ;-)

Does that sound good to you? ;)

Best Regards,
Torsten



 



-----Original-Nachricht-----
Betreff: [Marble-devel] Using marble to render PostGIS data in different Projections
Datum: Mon, 10 Feb 2014 11:45:05 +0100
Von: Knut Krause <knut.krause at lagom.de>
An: marble-devel at kde.org

Hi,

I have a PostGIS database with geometries. Now I'd like to do some computation 
on them. For my core algorithm I need the polygons in raster format. So I 
would be great if I could somehow use marble to draw my geometries on a flat 
surface like QImage. To show the result of my algorithm though I'd like to 
render a path on a plain marble widget.

Is it possible to use marble for that? Right now I use GDAL to transform the 
geometry from WKB to QPolygonF but that involeves a lot of number crunching 
myself to get the positions right and I fear I'm not smart enough to cope with 
projections correctly.

I thought something like

PostGIS -> <magic> -> GeoPainter -> QImage

would be great to render a set of geometries on an image as big as the 
bounding box of the geometries. Anyone here an idea if this works?


Knut
_______________________________________________
Marble-devel mailing list
Marble-devel at kde.org
https://mail.kde.org/mailman/listinfo/marble-devel





More information about the Marble-devel mailing list