<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Hi all,<br>
      <br>
      As Martin asked me, I updated my code and implemented Spatial
      Operator in QgsExpression as NodeFunction.<br>
      You can review the code here :<br>
      <a class="moz-txt-link-freetext" href="https://github.com/rldhont/Quantum-GIS/tree/6535">https://github.com/rldhont/Quantum-GIS/tree/6535</a><br>
      <br>
      I made 2 tests :<br>
      The first one with QGIS Server, I tested QgsExpression with OGC
      Filter Encoding in which there were spatial operators like BBOX,
      Intersects, Within, etc.<br>
      The second one with QGIS Desktop, I tested QgsExpression with the
      search request UI for point layer in which I wrote spatial
      operators like :<br>
      * bbox( $geometry, geomFromWKT( 'LINESTRING(
      <meta name="qrichtext" content="1">
      <span style=" font-family:'arial,sans-serif'; color:#000000;">3.80871
        43.5716,</span>
      <meta name="qrichtext" content="1">
      <span style=" font-family:'arial,sans-serif'; color:#000000;">3.93728
        43.6502</span>)' ) ) <br>
      * intersects( $geometry, geomFromWKT( 'POLYGON((<span style="
        font-family:'arial,sans-serif'; color:#000000;">3.80871 43.5716,
        3.80871 43.6502, 3.93728 43.6502, 3.80871 43.5716</span>))' )
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <style type="text/css">
p, li { white-space: pre-wrap; }            
</style> )<br>
      * within( $geometry, geomFromWKT( 'POLYGON((<span style="
        font-family:'arial,sans-serif'; color:#000000;">3.80871 43.5716,
        3.80871 43.6502, 3.93728 43.6502, 3.80871 43.5716</span>))' ) )<br>
      * contains( geomFromWKT( 'POLYGON((<span style="
        font-family:'arial,sans-serif'; color:#000000;">3.80871 43.5716,
        3.80871 43.6502, 3.93728 43.6502, 3.80871 43.5716</span>))',
      $geometry ) )<br>
      <br>
      I only wrote some QgsExpression::NodeFunction, I made nothing in
      UI.<br>
      <br>
      What do you think about this implementation ?<br>
      <br>
      <br>
      Le 30/10/2012 10:06, Martin Dobias a écrit :<br>
    </div>
    <blockquote
cite="mid:CAC2XbFeLh4fpXprL0=k0DEmHXPNOTmhxPMePjMgviC_Z1HQmFA@mail.gmail.com"
      type="cite">
      <pre wrap="">Hi Rene-Luc

On Mon, Oct 29, 2012 at 6:26 PM, rldhont <a class="moz-txt-link-rfc2396E" href="mailto:rldhont@gmail.com"><rldhont@gmail.com></a> wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">Hi all,

As Marco has said for the review of POST WFS GetFeature Request in
QGIS-Server #6535, it would be interesting to use QGS Expression for
OGC:Filter instead of an old code wrote just for the QGIS-Server.
</pre>
      </blockquote>
      <pre wrap="">
Yes, this would be indeed a good thing to use QgsExpression to
evaluate OGC filter expressions, thanks for working on that!


</pre>
      <blockquote type="cite">
        <pre wrap="">I've started writing Spatial Operator in QgsExpression, You can see the code
here :
<a class="moz-txt-link-freetext" href="https://github.com/rldhont/Quantum-GIS/tree/6535">https://github.com/rldhont/Quantum-GIS/tree/6535</a>

I would like to know how you imagine the dump and the text version of OGC
Spatial Operator (BBOX, Intercets, Crosses, Contains, Disjoint, Within,
etc).
I've started with text like this :
* SpatialOperator('The geometry as WKT')
What do you think about this ?
</pre>
      </blockquote>
      <pre wrap="">
I would have few comments regarding your code:
- I don't think that creation of "spatial operator" class is the right
way to go. Spatial operators can be handled as ordinary functions -
there is already generic support for functions, so let's use that.
Also, the functions should be able to handle arbitrary geometry, not
necessarily just the one stored in the feature... the geometry stored
in the feature could be just another special column, e.g. "$geom"
- The geometry is just another type of value, so it is preferable to
store it within QVariant, so it can be passed around as a normal
value. You will need to enable its use in QVariant with
Q_DECLARE_METATYPE(QgsGeometry*)
- geometries need a way to construct them - currently you build them
explicitly from GML... I would suggest creating functions like
GeomFromWKT and GeomFromGML that would take a string parameter and
return a QgsGeometry* inside a QVariant. One could also consider
adding simple geometry accessor functions like GeomToWKT.

So, to answer your original question, the syntax would be e.g.:
Intersects($geom, GeomFromWKT('POINT(10 20)'))

In future I would like to have support not only for spatial operators,
but also general spatial processing (intersection, buffer etc) - that
should be rather easy to add once we have some support for geometries.

Regards
Martin
</pre>
    </blockquote>
    <br>
  </body>
</html>