[QGIS-Developer] GPS Stream Plugin Crashing QGIS

Nathan Woodrow madmanwoo at gmail.com
Thu May 11 00:36:29 PDT 2017


Hey,

Yes if you are needing speed you should avoid going via the edit buffer in
the layer.  You should get the data provider off the layer once and then
just call the delete, update, add feature methods on there. It will avoid
the edit buffer and commit overhead that you get and no doubt are running
into.

What is the main goal of the incoming data?  Just display or do you need to
store it in the layer?   If it is just displayed you can use a map canvas
item and just update the point on the screen. They are rendered above the
map and don't cause a map layer refresh.   I have a blog post on it if you
need or there is small sample ones around the place.

- Nathan

On Wed, May 10, 2017 at 1:02 AM, Joshua Quesenberry <engnfrc at gmail.com>
wrote:

> Greetings Everyone,
>
>
>
> I’m playing around with a plugin that’s supposed to receive GPS Data over
> a TCP socket and then once a new point is received the Vector
> Memory/Scratch Layer has all features removed and a new Point feature
> added. I have a worker thread running that processes the incoming TCP
> socket data (rate of about 10 Hz) and then runs a function called addPoint.
> Currently the plugin works great if I don’t call addPoint and just print
> the contents of the received message. Once I add in the addPoint function,
> however, the plugin works for a bit (30-60 seconds) and then QGIS crashes.
>
>
>
> My addPoint function is as follows:
>
>
>
>     def addPoint(self, point):
>
>         self.layer.startEditing()
>
>         caps = self.layer.dataProvider().capabilities()
>
>         if caps & QgsVectorDataProvider.DeleteFeatures:
>
>             for feat in self.layer.getFeatures():
>
>                 self.layer.deleteFeature(feat.id())
>
>         if caps & QgsVectorDataProvider.AddFeatures:
>
>             feat = QgsFeature(self.layer.pendingFields())
>
>             feat.setGeometry(QgsGeometry.fromPoint(point))
>
>             (res, outFeats) = self.layer.dataProvider().
> addFeatures([feat])
>
>         self.layer.commitChanges()
>
>
>
> Perhaps the issue is because I’m entering/exiting Edit mode so often (10
> Hz)? Is there a more efficient method to accomplish what I’m doing? Or
> maybe it’s some sort of threading conflict?
>
>
>
> Thanks,
>
>
>
> Josh Q
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20170511/e29ea015/attachment.html>


More information about the QGIS-Developer mailing list