[Qgis-developer] [Python] QgsFeatureIterator for geometryless PostgreSQL-Layer

Bernhard Ströbl bernhard.stroebl at jena.de
Tue Apr 9 22:50:41 PDT 2013


Jürgen,

this works!
I checked the docs for QgsVectorLayer.getFeatures and QgsFeatureIterator 
but not for QgsFeatureRequest

thank you and all the best

Bernhard

Am 09.04.2013 18:10, schrieb Jürgen E. Fischer:
> Hi Bernhard,
>
> On Tue, 09. Apr 2013 at 15:09:31 +0200, Bernhard Ströbl wrote:
>> I am trying to access features of a geometryless layer derived from a
>> PostgreSQL table in current master.
>>
>> if I do
>> feat = QgsFeature()
>> iter = myLayer.getFeatures(QgsFeatureRequest().setFilterFid(myFid))
>> iter.nextFeature(feat)
>> returns False and I get a message in the PostgreSQL message tab stating
>> "Trying to fetch geometry on layer without geometry."
>>
>> Can anybody confirm?
>> Do I miss anything or is this a bug?
>
> You request geometry (by not saying you don't want any) - and get refused
> because there's none.
>
> myLayer.getFeatures(QgsFeatureRequest().setFilterFid(myFid).setFlags( QgsFeatureRequest.NoGeometry ) )
>
> should work.  Not really a bug, but inconvienent.
>
>
> Jürgen
>



__________ Information from ESET Mail Security, version of virus signature database 8211 (20130409) __________

The message was checked by ESET Mail Security.
http://www.eset.com




More information about the Qgis-developer mailing list