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

Ander Pijoan ander.pijoan at deusto.es
Mon Feb 10 12:14:24 UTC 2014


Well my idea was more oriented to telling that there already is a GeoJSON
parser implemented in Marble. If it exports geometries as geojson from
PostGIS, the parser is already made.

But for this purpose it would need to extract the parser from the runner as
the runner is prepared for receiving a filename, opening its content and
getting an array of geometries in it.

I guess the optimal approach would be to extract the "Each-single-geometry"
parser piece of code from the runner to a common place where both the
runner and other codes can access. When making a query to PostGIS, parse
each geometry with that piece of the parser and in the runner, open the
file, get the geometries array and also send each separate geometry to the
parser.


2014-02-10 12:54 GMT+01:00 Knut Krause <knut.krause at lagom.de>:

> Sure sure.
>
> btw I should have mentioned, that I plan to use my approach to cover huge
> spaces ... like half germany or something like that.
>
> I hope your suggested approach doesn't run into performance issues too fast
> since that is a fundamental issue here.
>
> I think I'll render a couple hundred thousand to millions polygons into one
> raster ...
>
>
> Knut
>
> Am Montag, 10. Februar 2014, 12:51:26 schrieb tackat at t-online.de:
> > Well I just reread Anders' mail and only now realized that he suggested
> to
> > export to json and then use the json runner. That would be the lazy
> > approach  ;-)  (and would probably be less flexible). The beer and pizza
> > invitation is only offered for actually writing the PostGIS runner (where
> > you could borrow code from the existing runners such as the JSON, KML,
> SHP,
> >  and OSM runner).
> >
> > As a "first shot" you could maybe also have a look at the gpsbabel
> runner:
> > That one uses the gpsbabel commandline tool - if installed - to convert
> > different file formats to KML and then feeds it to Marble's KML runner.
> > Maybe you could do something similar with the PostGIS database as a
> source
> > and feed it to the JSON runner. But again that might be less flexible
> that
> > creating a "full-blown" dedicated "PostGIS" runner.
> >
> > Oh and in order to test your code (in order to verify your
> > beer-and-pizza-claims ;-))))) ) we need a tutorial on how to use your
> code
> > - preferably you create a small tutorial at
> > http://techbase.kde.org/Projects/Marble just along the existing ones.
> >
> > Best Regards,
> > Torsten
> >
> >
> >
> > -----Original-Nachricht-----
> > Betreff: Re: [Marble-devel] Using marble to render PostGIS data in
> different
> > Projections Datum: Mon, 10 Feb 2014 12:39:20 +0100
> > Von: Knut Krause <knut.krause at lagom.de>
> > An: marble-devel at kde.org
> >
> > Woah, thanks for your brilliant suggestions.
> >
> > I'll have a look at the runner and will see how I could use them. If this
> > works for me maybe you'll have to pay for pizza and beer really soon :-P
> >
> > Knut
> >
> > Am Montag, 10. Februar 2014, 12:31:06 schrieb tackat at t-online.de:
> > > 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
> >
> > _______________________________________________
> > Marble-devel mailing list
> > Marble-devel at kde.org
> > https://mail.kde.org/mailman/listinfo/marble-devel
>
> _______________________________________________
> Marble-devel mailing list
> Marble-devel at kde.org
> https://mail.kde.org/mailman/listinfo/marble-devel
>



-- 
Ander Pijoan Lamas
Research Assistant, Deustotech
Computer Science Engineer
University of Deusto

E-mail: ander.pijoan at deusto.es
Phone: +34 664471228
in: http://www.linkedin.com/profile/view?id=162888312
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/marble-devel/attachments/20140210/3e9c0788/attachment.html>


More information about the Marble-devel mailing list