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

Matthias Kuhn matthias.kuhn at gmx.ch
Wed Oct 2 06:47:12 PDT 2013


Hi

On 12.04.2013 09:51, Martin Dobias wrote:
> 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?
>
I stumbled over this again. So I decided to fix this. [1]
This pull request changes the meaning of QgsFeatureRequest::NoGeometry.
Or maybe I should rather say it defines it and unifies behavior. It
seems, that this was handled differently by different providers. E.g.
OGR provider was returning features of a geometry-less layer regardless
of this flag, while postgres and spatialite providers spat an error to
the message log and didn't return any features.

New behavior is:
The geometry is not required to satisfy the request. It may still be
returned if e.g. required for a filter condition.

Are there any objections to this?

My main point in the change is to be able to query any layer (regardless
if it has a geometry or not) with a default constructed feature request
and get all rows.
Do we need a new flag RequiresGeometry? Can't just the layers/providers
geometry type easily be checked for NoGeometry instead? And would a
RequiresGeometry flag not rather have to be applied on a feature basis
(only return features whose geometry is not NULL)

Kind regards,
Matthias

[1] https://github.com/qgis/QGIS/pull/918


More information about the Qgis-developer mailing list