[Qgis-developer] Getting access to atlas record

Martin Dobias wonder.sk at gmail.com
Thu Jun 19 22:18:15 PDT 2014


Hi Nyall

On Fri, Jun 20, 2014 at 10:34 AM, Nyall Dawson <nyall.dawson at gmail.com> wrote:
> What I've done is:
>
> - Add an "$atlasfeature" variable, which returns the current atlas feature
> - Add a "$currentfeature" variable, which returns the current feature
> which is being evaluated (unfortunately $feature is already used for
> the current atlas feature NUMBER, which is an issue for a separate
> email!)
> - Add an "attribute( feature, column )" function, which returns the
> value stored in the specified column for a given feature
>
> This allows you to do an expression like:
> "area_code" = attribute($atlasfeature, 'area_code')

May I suggest an alternative approach: to introduce dot notation, e.g.
$atlasfeature.area_code - that looks much more like SQL syntax and it
is easier to remember and use. It would require small adjustments to
the parser and evaluator in order to support "nested" objects, but I
think it would be worth it. I could help with that if needed.


> Or, you can do neat things like label a column using an expression to
> choose the column name!..
> attribute( $currentfeature, "label_column" )

This would need some extra care: the expression tells in
referencedColumns() call what fields are going to be used. If we
support thing like this, we need to ensure that all attributes are
fetched.

Regards
Martin


More information about the Qgis-developer mailing list