[Qgis-developer] Spatial Operator in QgsExpression

rldhont rldhont at gmail.com
Tue Nov 6 01:12:38 PST 2012

Hi all,

As Martin asked me, I updated my code and implemented Spatial Operator 
in QgsExpression as NodeFunction.
You can review the code here :

I made 2 tests :
The first one with QGIS Server, I tested QgsExpression with OGC Filter 
Encoding in which there were spatial operators like BBOX, Intersects, 
Within, etc.
The second one with QGIS Desktop, I tested QgsExpression with the search 
request UI for point layer in which I wrote spatial operators like :
* bbox( $geometry, geomFromWKT( 'LINESTRING( 3.80871 43.5716, 3.93728 
43.6502)' ) )
* intersects( $geometry, geomFromWKT( 'POLYGON((3.80871 43.5716, 3.80871 
43.6502, 3.93728 43.6502, 3.80871 43.5716))' ) )
* within( $geometry, geomFromWKT( 'POLYGON((3.80871 43.5716, 3.80871 
43.6502, 3.93728 43.6502, 3.80871 43.5716))' ) )
* contains( geomFromWKT( 'POLYGON((3.80871 43.5716, 3.80871 43.6502, 
3.93728 43.6502, 3.80871 43.5716))', $geometry ) )

I only wrote some QgsExpression::NodeFunction, I made nothing in UI.

What do you think about this implementation ?

Le 30/10/2012 10:06, Martin Dobias a écrit :
> Hi Rene-Luc
> On Mon, Oct 29, 2012 at 6:26 PM, rldhont <rldhont at gmail.com> wrote:
>> 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.
> Yes, this would be indeed a good thing to use QgsExpression to
> evaluate OGC filter expressions, thanks for working on that!
>> I've started writing Spatial Operator in QgsExpression, You can see the code
>> here :
>> https://github.com/rldhont/Quantum-GIS/tree/6535
>> 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 ?
> 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
> - 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20121106/d1bda6df/attachment-0001.html>

More information about the Qgis-developer mailing list