<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
From your code [0]
<meta http-equiv="content-type" content="text/html; charset=utf-8">
, I would see 2 options:<br>
<br>
* add features all at once on the provider using
QgsVectorDataProvider::addFeatures (the method you currently use)<br>
<br>
* work on the layer level rather than the provider, which I believe
is the recommended way for plugins. Make the layer editable, and add
features to the edit buffer and commit at once. Or maybe commit 1000
by 1000. <br>
<br>
I hope this helps.<br>
<br>
<br>
<br>
<br>
[0]
<a class="moz-txt-link-freetext" href="https://github.com/opengeogroep/AERIUS-QGIS-plugins/blob/master/ImaerReader/imaer_reader.py#L228">https://github.com/opengeogroep/AERIUS-QGIS-plugins/blob/master/ImaerReader/imaer_reader.py#L228</a><br>
<br>
<div class="moz-cite-prefix">On 07/30/2015 09:20 AM, Raymond Nijssen
wrote:<br>
</div>
<blockquote cite="mid:55B9D02A.2000107@terglobo.nl" type="cite">Hi
Denis,
<br>
<br>
The code is in the ImaerReader plugin in the qgis repo and in
github:
<br>
<br>
<a class="moz-txt-link-freetext" href="https://github.com/opengeogroep/AERIUS-QGIS-plugins">https://github.com/opengeogroep/AERIUS-QGIS-plugins</a>
<br>
<br>
I'm adding the features one by one.
<br>
<br>
Regards,
<br>
Raymond
<br>
<br>
On 30-07-15 08:46, Denis Rouzaud wrote:
<br>
<blockquote type="cite">Hi Raymond,
<br>
<br>
Can you show us the code doing this?
<br>
Do you commit features one by one ar all at once?
<br>
<br>
Best wishes,
<br>
Denis
<br>
<br>
On 07/29/2015 09:04 AM, Raymond Nijssen wrote:
<br>
<blockquote type="cite">Dear developers, ;)
<br>
<br>
A plugin of mine imports data from a gml file into a memory
layer.
<br>
Works fine for tiny gml files, but takes forever on huge ones.
Sounds
<br>
plausible maybe, but the relation is not linear.
<br>
<br>
So I did did some tests and found out that reading and parsing
the gml
<br>
and creating the features always goes at the same speed of
about 400
<br>
features a second (fps). But when adding these to my memory
layer, the
<br>
process slows down tremendously.
<br>
<br>
I output the fps for every 1000 features and it gave me this
graph:
<br>
<br>
<a class="moz-txt-link-freetext" href="http://terglobo.nl/downloads/memory-layer-performance.png">http://terglobo.nl/downloads/memory-layer-performance.png</a>
<br>
<br>
At the end of the importing process I'm processing just 3
features per
<br>
second.
<br>
<br>
Is this expected behaviour? Is a memory layer not meant for
something
<br>
like this? Or is this a bug?
<br>
<br>
In the source code I found that for every feature I add to a
memory
<br>
layer the index is updated. Could that be inefficient?
<br>
<br>
Hoping anyone can explain!
<br>
<br>
Regards,
<br>
Raymond
<br>
<br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>