[Qgis-developer] Rendering Real-Time Data in QGIS

Florian El Ahdab felahdab at gmail.com
Wed Apr 29 16:43:31 EDT 2009


Hi

Thanks for your answer.

My idea with the threads was to experiment. After browsing the QT API (of
which I am no expert at all), I suppose that what I want to do would take
great advantage of signals.
The way I see it:  Some QTcpSocket would send a signal when data is
received, another helper class would handle this data, and emit another
signal when a new track data is available. This signal would finally be used
to update the QgsMapCanvasItem data in QGis. This seems cool.

I understand very well your remarks about the synchronization. However,
since I am adding the items to the MapCanvas using the QGis API, and since
this API doesn't seem to provide any way to synchronize the access to the
items, I don't see how I could have the synchronization properly
implemented. I can add all the mutexes that I want in my code, the QGis API
won't synchronize...

Did I miss something? Is there an implicit synchronization in the Qt API
regarding the QGraphicScene?

Thanks for your help again.
Florian


On Wed, Apr 29, 2009 at 11:28 AM, Martin Dobias <wonder.sk at gmail.com> wrote:

> On Sat, Apr 25, 2009 at 11:38 AM, Florian El Ahdab <felahdab at gmail.com>
> wrote:
> > [...]
> >
> > Here is my problem:
> > When I create 1 of those items, everything works fine. With a map loaded,
> I
> > can see the Item moving around every 500ms.
> > But when I create 10 of those items (and consequently 10 threads), I can
> see
> > them moving but qgis crashes randomly (between 1 and 10 seconds max).
> > I suspect this is because there is no synchronization in the access to
> the
> > Item data when the thread moves the item.
> > I have tried to freeze the MapCanvas before updating the position... but
> it
> > doesn't work either.
> >
> > Wonder:
> > If my explanations are clear enough, can you help me?
> > Can you detail a little bit further how you would do such a thing for a
> > large amount of tracks (let's say 5000...).
>
> Is it really necessary to use threads here? Usually much simpler
> approach is to use a timer that updates the items once in a while. And
> you don't have to worry about large number of threads and
> synchronisation.
>
> > If there is a need for synchronization, how can I synchronize the access
> to
> > the items that I have to add to the MapCanvas (which doesn't synchronize
> > before using the data apparently.)
>
> Yes, you have to synchronize the threads, otherwise you'll have
> concurrency problems. Everything shared among threads must be accessed
> safely, i.e. using mutexes, semaphores, r/w locks etc...
>
> Martin
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/qgis-developer/attachments/20090429/4c1acd9f/attachment.html


More information about the Qgis-developer mailing list