<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000'><span id="result_box" class="" lang="en"><span class="" title="Bonjour à tous,">Hello everyone,<br><br></span><span class="" title="pour le suivi, j'ai abouti!">I found ! </span><span class="" title="En cherchant un peu partout une solution à mon problème, j'ai bien compris que python serait la solution.">Looking around a solution to my problem, I understand that python would be the solution .<br><br></span><span class="" title="Les 3 ressources ci-dessous m'ont bien aidé :">Thanks to the QGis documentation and to those 3 resources :<br><br>  - http://nathanw.net/2012/11/10/user-defined-expression-functions-for-qgis/<br>  - http://www.3liz.com/blog/rldhont/index.php?post/2012/11/06/Op%C3%A9rateurs-spatiaux-dans-les-expressions-de-QGIS<br>  - http://gis.stackexchange.com/questions/28625/how-to-create-a-polygon-based-on-view-extent-in-qgis-1-8</span><span class="" title="- http://gis.stackexchange.com/questions/ … n-qgis-1-8"><br><br></span><span class="" title="J'ai donc créé un script python (userfunctions.py), qui contient une fonction appelée current_canvas_extent, qui retourne une géométrie de type Polygone représentant l'emprise courante de la fenêtre.">So
 I created a python script ( userfunctions.py ), which contains a 
function called current_canvas_extent , which returns a Polygon
representing the current influence of the window.<br><br></span><span class="" title="Code:"><br>[code]<br>from qgis.utils import qgsfunction<br>from qgis.utils import iface<br>from qgis.core import QGis<br><br>@qgsfunction(0, "Python")<br>def current_canvas_extent(values, feature, parent):<br>    """<br>       retourne l etendue courante de la carte<br>   """<br>    ##extend = QgsGeometry.fromRect( iface.mapCanvas().extent() ) <br>    ##extend = iface.mapCanvas().extent().toString() <br>    extend = iface.mapCanvas().extent().asWktPolygon() <br>    return extend<br>[/code]</span><span class="" title="return extend"><br><br></span><span class="" title="J'appelle se script au démarrage de QGis (ajouter à la commande de lancement de QGis l'option "--code chemin\vers\userfunctions.py")">QGis call the script on start (add the option " - code path \ to \ userfunctions.py " )<br><br></span><span class="" title="J'ai donc maintenant accès dans mon éditeur d'expression à cette "variable".">So I now have access to this "variable" inside the expression editor.<br></span><span class="" title="Et je peux demander à QGis, grâce à l'éditeur d'expression de ne me proposer dans la liste que les parcelles présentes dans l'emprise de ma carte :">And I can ask QGis restrict the list to the objects intersecting the current canvas.</span><span class="" title="Code:"><br><br>[code]<br></span><span class="" title="intersects( $geometry , geomFromWKT( $current_canvas_extent ))">intersects ($ geometry , geomFromWKT ($ current_canvas_extent ) )</span></span><br><span id="result_box" class="" lang="en"><span class="" title="intersects( $geometry , geomFromWKT( $current_canvas_extent ))"><span id="result_box" class="" lang="en"><span class="" title="Code:">[/code]<br><br></span></span></span><span class="" title="Je propose que "QGis Déchire" retrouve sa place dans l'aperçu d'étiquetage!">Thanks a lot for this great software you give us!</span></span><br> <br><div>Mathieu BOSSAERT <br>--<br>Responsable du système d'information <br><img style="border: 0px none;" src="http://www.cenlr.org/divers/logo_signature_millenaire.jpg"><br>Membre de la Fédération des Conservatoires d'espaces naturels www.reseau-cen.org <br><span name="x"></span><br></div><hr id="zwchr"><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>De: </b>"Mathieu Bossaert (CEN L-R)" <mathieu.bossaert@cenlr.org><br><b>À: </b>qgis-user@lists.osgeo.org<br><b>Envoyé: </b>Mardi 1 Octobre 2013 11:26:55<br><b>Objet: </b>How to make use of python variables in Qgis filter expression<br><br><style>p { margin: 0; }</style><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000"><style>p { margin: 0; }</style><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt; color: #000000">Good morning,<br><br>thanks to the new Qgis, I can make a really pratical interface to my postgis database. I want to make use of relationnal value in the editing form.<br>The table I use to populate the list is a spatial table.<br><br>I would like to restrict the list of available values in the form to the objects within the current extent of my map.<br><br>I found an example wich is ok but I would like to make use of a variable instead of a fixed extend (GeomFromWKT()).<br>The example I tried is here : http://www.3liz.com/blog/rldhont/index.php?post/2012/11/06/Spatial-operators-in-QGIS-expression<br><br>Thanks a lot,<br><br>Mathieu<br><br><div><span></span>-- <br>Mathieu BOSSAERT <br>Responsable du système d'information <br><img style="border: 0px none;" src="http://www.cenlr.org/divers/logo_signature_millenaire.jpg"><br>Membre de la Fédération des Conservatoires d'espaces naturels www.reseau-cen.org <br><span></span><br></div></div></div></div><br></div></body></html>