<div dir="ltr">Hey,<div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>- Nathan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 10, 2017 at 1:02 AM, Joshua Quesenberry <span dir="ltr"><<a href="mailto:engnfrc@gmail.com" target="_blank">engnfrc@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="#0563C1" vlink="#954F72"><div class="m_5971706436543956445WordSection1"><p class="MsoNormal">Greetings Everyone,<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">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.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">My addPoint function is as follows:<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">    def addPoint(self, point):<u></u><u></u></p><p class="MsoNormal">        self.layer.startEditing()<u></u><u></u></p><p class="MsoNormal">        caps = self.layer.dataProvider().<wbr>capabilities()<u></u><u></u></p><p class="MsoNormal">        if caps & QgsVectorDataProvider.<wbr>DeleteFeatures:<u></u><u></u></p><p class="MsoNormal">            for feat in self.layer.getFeatures():<u></u><u></u></p><p class="MsoNormal">                self.layer.deleteFeature(<a href="http://feat.id" target="_blank">feat.<wbr>id</a>())<u></u><u></u></p><p class="MsoNormal">        if caps & QgsVectorDataProvider.<wbr>AddFeatures:<u></u><u></u></p><p class="MsoNormal">            feat = QgsFeature(self.layer.<wbr>pendingFields())<u></u><u></u></p><p class="MsoNormal">            feat.setGeometry(QgsGeometry.<wbr>fromPoint(point))<u></u><u></u></p><p class="MsoNormal">            (res, outFeats) = self.layer.dataProvider().<wbr>addFeatures([feat])<u></u><u></u></p><p class="MsoNormal">        self.layer.commitChanges()<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">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?<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Thanks,<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Josh Q<u></u><u></u></p></div></div><br>______________________________<wbr>_________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/qgis-<wbr>developer</a><br></blockquote></div><br></div>