[QGIS-Developer] FeatureIterator is constructed but not iterated when creating a custom QgsVectorDataProvider in Python

Mats Taraldsvik mats.taraldsvik at gmail.com
Fri Nov 20 05:53:50 PST 2020


Hi,

Yes, thank you - your example along with
https://github.com/blazek/django-provider/blob/master/djangoprovider/provider.py
is in fact what I am using to write my dataprovider.

I must have overlooked something, since the results are never iterated, but
the logs are not helpful at all, unfortunately... :(

There must be a reason why there is no attempt to iterate..?

Mats

On Fri, Nov 20, 2020 at 2:30 PM Alessandro Pasotti <apasotti at gmail.com>
wrote:

> On Fri, Nov 20, 2020 at 2:22 PM Mats Taraldsvik
> <mats.taraldsvik at gmail.com> wrote:
> >
> > Hi,
> >
> > I'm trying to create/prototype a custom QgsVectorDataProvider in Python
> to retrieve data from a HTTP REST API.
> >
> > When testing, I do the following to register my provider:
> >
> > from qgis.core import QgsProviderRegistry, QgsProviderMetadata
> > from provider import MyProvider
> > registry = QgsProviderRegistry.instance()
> > metadata = QgsProviderMetadata(MyProvider.providerKey(),
> MyProvider.description(), MyProvider.createProvider)
> > registry.registerProvider(metadata)
> > layer = QgsVectorLayer(<my-url>, 'Test myprovider', 'myprovider-plugin')
> > QgsProject.instance().addMapLayer(layer)
> > This seems to initialize the provider, although it stops after the
> constructor of MyFeatureIterator(QgsAbstractFeatureIterator) is run.
> > For this test, data is retrieved from the REST API in the constructor,
> and I can see in the logs that the data is retrieved.
> >
> > I expected it to start iterating objects, but the next message in the
> log is prepareSimplification (I have added a log message to every class
> method to watch progress in the logs), then nothing.
> >
> > I even installed qgis-dev and watched the logs using Microsoft's
> DebugViewer, but I could not see any relevant information.
> >
> > Could someone please help me or tell me where to look to solve this
> issue and start iterating with nextFeature/fetchFeature? Regards,
>
>
> AFAIK there is only one example I wrote for testing purposes ages ago:
>
> https://github.com/qgis/QGIS/blob/master/tests/src/python/provider_python.py
>
> I'm not sure it will be useful but it's a start.
>
> Kind regards.
>
> --
> Alessandro Pasotti
> QCooperative:  www.qcooperative.net
> ItOpen:   www.itopen.it
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20201120/16994ad6/attachment.html>


More information about the QGIS-Developer mailing list