[Qgis-user] variables in postgis filters

Nyall Dawson nyall.dawson at gmail.com
Sun Apr 3 17:25:35 PDT 2016


On 3 April 2016 at 01:27, Sandro Santilli <strk at keybit.net> wrote:
> On Wed, Mar 30, 2016 at 02:47:55AM -0700, ralfwessels wrote:
>
>> I would like to filter my PostGIS table by the actual extent of the map
>> canvas similar to the possibility in the Quick OSM - Plugin.
>>
>> Does someone know, if this is possible?
>
> I've been thinking about a way to do this too as I'm afraid it is
> currently not available as a core support.

There's 2 ways I can think of implementing this. One would be a niave
search-and-replace for variable names in the filter before passing it
off to the layer's provider. But that's potentially quite fragile.

An alternative approach would be to have an optional switch which
changes the layer filter from provider-specific syntax to using the
standard QGIS expression engine, complete with access to variables and
the like. With compiled expressions these could still potentially be
handed off to the provider side to speed up the queries.

>
> Being able to use canvas-dependent variables (extent and scale,
> mostly) would help a lot with speeding up some kind of query
> layers (TopoGeometry ones, for example).

Be aware that this would not be possible in a vector layer filter.
Expressions at the vector layer level will only have access to global,
project and layer variables. Think about it this way - if the project
has multiple maps in various composers, which extent and scale would
be used when fetching features from the layer for something which
isn't specific to an individual map (Eg the attribute table).

Only expressions evaluated in the context of a specific map have
access to the map specific scale and extent variables (eg data defined
symbology, labeling parameters, etc).

Nyall


>
> I haven't looked at how the QuickOSM plugin deals with the issue,
> does it update the layer definition on every pan and zoom operations ?
>
> --strk;
>
>
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user



More information about the Qgis-user mailing list