[Qgis-developer] featureAtId replacement

Jürgen E. Fischer jef at norbit.de
Tue Feb 12 01:26:54 PST 2013


Hi Martin,

On Mon, 11. Feb 2013 at 17:50:29 +0100, Martin Dobias wrote:
> I would like to add a convenience QgsFeatureRequest constructors that
> would save people some typing - one for filtering by FID, another for
> filtering by rectangle, so it would get a bit lighter:
> layer.getFeatures( QgsFeatureRequest( fid ) ).nextFeature(f)
> -or-
> f = layer.getFeatures( QgsFeatureRequest( fid ) ).next()
> (StopIteration exception would be thrown if the FID wouldn't exist)
> 
> I have been thinking also about providing convenience getFeatures()
> call, for even shorter syntax:
> layer.getFeatures( fid ).nextFeature(f)

Creating the QgsFeatureRequest implicitly in getFeatures blocks the other
options (restricting the attributes, no geometry...).

I like the explicitness of the new interface.  No more "what was this
true/false for again"?  Optionally adding those to getFeatures, would
reintroduce that.

Maybe the current interface just takes a bit of getting use to?

Having multiple constructors for QgsFeatureRequest (rect, fid, fids) however
sounds acceptable ;)


> For a direct replacement of featureAtId() calls I have thought also
> about adding getFeature() convenience call, that would return first
> feature of a request:
> f = layer.getFeature( fid )

Why not keep featureAtId with the old interface on top of the new api then?
And we still need to know if that feature actually exists...


JÃrgen

-- 
Jürgen E. Fischer         norBIT GmbH               Tel. +49-4931-918175-31
Dipl.-Inf. (FH)           Rheinstraße 13            Fax. +49-4931-918175-50
Software Engineer         D-26506 Norden               http://www.norbit.de
committ(ed|ing) to Quantum GIS                         IRC: jef on FreeNode                         

-- 
norBIT Gesellschaft fuer Unternehmensberatung und Informationssysteme mbH
Rheinstrasse 13, 26506 Norden
GF: Jelto Buurman, HR: Amtsgericht Emden, HRB 5502



More information about the Qgis-developer mailing list