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

Martin Dobias wonder.sk at gmail.com
Fri Apr 12 00:51:15 PDT 2013


On Fri, Apr 12, 2013 at 9:25 AM, Jürgen E. <jef at norbit.de> wrote:
> Hi Martin,
>
> On Thu, 11. Apr 2013 at 22:30:57 +0200, Martin Dobias wrote:
>> I have a feeling that we should call that a bug: the NoGeometry flag
>> tells that it is not necessary to fetch geometry... so even if the
>> flag is not set, the feature should be fetched.
>
> Ok, then it's also misleading. Should we rename NoGeometry to WithoutGeometry
> while we still can?

Yes, we could do that. Or maybe IgnoreGeometry?

Recently I have been wondering whether it would not be better to
actually stop using flags and replace them by usual getter/setter
functions. My main concern is the setSubsetOfAttributes() function: it
also sets the flag, so the users may end up with a weird behavior,
e.g.:
QgsFeatureRequest().setSubsetOfAttributes( ["name","type"], fields
).setFlags( NoGeometry )
That would fetch all attributes... because the setFlags overrides the
previously set SubsetOfAttributes flag.
Maybe we can keep the flags, but we should not have the
SubsetOfAttributes there.
Also, the way how things are done right now, providers need to
implement fetching of attributes in this way (pseudo-code):
if using subset of attributes:
  for each attribute from subset:
    fetch attribute
else:
  for each attribute from provider:
    fetch attribute
This is quite annoying, we should probably have a simple array where
each value would indicate whether to fetch attribute with that index
or not (by default all values would be true). The fetching would be
simplified to:
for each attribute from provider:
  if attribute should be fetched:
    fetch attribute

What do you think? :-)

Martin


More information about the Qgis-developer mailing list