Hi.<br><br>I have been trying to use your tips to render dynamic data (AIS tracks, probably the same objective as Chee Kiang Lim).<br><br>So as to do so, here is what I have done so far:<br>In a plugin, I have subclassed the MapCanvasItem (in fact, I have used a renamed VertexMarker class). This subclass is named CustomMapCanvasItem.<br>
I have created a QThread subclass (CustomMapCanvasItemThread), which moves the CustomMapCanvasItem it received in reference every 500ms (that is, it setCenter() on the item, then updatePosition()).<br><br>Here is my problem:<br>
When I create 1 of those items, everything works fine. With a map loaded, I can see the Item moving around every 500ms.<br>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).<br>
I suspect this is because there is no synchronization in the access to the Item data when the thread moves the item.<br>I have tried to freeze the MapCanvas before updating the position... but it doesn&#39;t work either.<br>
<br>Wonder:<br>If my explanations are clear enough, can you help me? <br>Can you detail a little bit further how you would do such a thing for a large amount of tracks (let&#39;s say 5000...).<br>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&#39;t synchronize before using the data apparently.)<br>
<br>Thanks a lot.<br>Florian<br><br><div class="gmail_quote">On Thu, Feb 5, 2009 at 7:24 PM, Martin Dobias <span dir="ltr">&lt;<a href="http://wonder.sk">wonder.sk</a>@<a href="http://gmail.com">gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">On Thu, Feb 5, 2009 at 1:47 PM, Chee Kiang Lim &lt;<a href="mailto:cheekiang.lim@gmail.com">cheekiang.lim@gmail.com</a>&gt; wrote:<br>

&gt; Hi,<br>
&gt;<br>
&gt; I&#39;m new to the QGIS API and have explored it very briefly. I am trying to<br>
&gt; write a c++ plugin that will take in the locations of approximately<br>
&gt; 100 vessels and render their current position (which varies with time)on top<br>
&gt; of an underlying map. I used polygons to represent those vessels on a vector<br>
&gt; layer using the memory provider. Each update involves deleting old features<br>
&gt; and adding new ones followed by refreshing of mapcanvas triggered when<br>
&gt; changes are committed. As there is a need to render updates at a high<br>
&gt; frequency for real time display, with positional data coming in at about<br>
&gt; 1-2Hz, the application was too occupied refreshing the canvas. This makes<br>
&gt; the application unresponsive to subsequent user commands. I tried<br>
&gt; using update(Rect of changedExtent) for localized painting/canvas refreshing<br>
&gt; but the rendering is still too taxing. Can you provide some advice on how i<br>
&gt; can go about rendering this huge amount of data in real time?<br>
&gt;<br>
&gt; I also tried using rubberbands and they work much better but i need to<br>
&gt; display text attributes beside each vessel which i do not know how to<br>
&gt; achieve without labels. Any alternative to rendering text at specific map<br>
&gt; location that i can update in real time?<br>
<br>
</div></div>Custom map canvas items are perfectly suited for this type of task.<br>
They don&#39;t require map to be re-rendered when the item gets updated.<br>
You can subclass your own class directly from QgsMapCanvasItem or you<br>
can create specialized class from QgsRubberBand that will additionally<br>
draw text labels.<br>
<br>
You can also take a look on some brief documentation for map canvas:<br>
<a href="http://wiki.qgis.org/qgiswiki/MapCanvas_API" target="_blank">http://wiki.qgis.org/qgiswiki/MapCanvas_API</a><br>
<br>
Martin<br>
_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div><br>