|
| 1 | +/*************************************************************************** |
| 2 | + qgsspatialfilter.h |
| 3 | + --------------------- |
| 4 | + begin : Oct 19, 2012 |
| 5 | + copyright : (C) 2012 by René-Luc D'Hont |
| 6 | + email : rldhont at 3liz dot com |
| 7 | + ***************************************************************************/ |
| 8 | + |
| 9 | +/*************************************************************************** |
| 10 | + * * |
| 11 | + * This program is free software; you can redistribute it and/or modify * |
| 12 | + * it under the terms of the GNU General Public License as published by * |
| 13 | + * the Free Software Foundation; either version 2 of the License, or * |
| 14 | + * (at your option) any later version. * |
| 15 | + * * |
| 16 | + ***************************************************************************/ |
| 17 | + |
| 18 | +#ifndef QGSSPATIALFILTER_H |
| 19 | +#define QGSSPATIALFILTER_H |
| 20 | + |
| 21 | +#include <qgsfilter.h> |
| 22 | +#include <qgsgeometry.h> |
| 23 | +#include <QDomElement> |
| 24 | + |
| 25 | +/**A filter for spatial filter (bbox, intersects, within, disjoint) |
| 26 | +Sample xml fragment: |
| 27 | +<Filter xmlns="http://www.opengis.net/ogc"> |
| 28 | +<BBOX> |
| 29 | +<gml:Box xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:4326"> |
| 30 | +<gml:coordinates decimal="." cs="," ts=" ">135.45,-47.425 157.95,-36.175</gml:coordinates> |
| 31 | +</gml:Box> |
| 32 | +</BBOX> |
| 33 | +</Filter> |
| 34 | +*/ |
| 35 | +class QgsSpatialFilter: public QgsFilter |
| 36 | +{ |
| 37 | + public: |
| 38 | + enum SPATIAL_TYPE |
| 39 | + { |
| 40 | + BBOX, |
| 41 | + CONTAINS, |
| 42 | + CROSSES, |
| 43 | + EQUALS, |
| 44 | + DISJOINT, |
| 45 | + INTERSECTS, |
| 46 | + OVERLAPS, |
| 47 | + TOUCHES, |
| 48 | + WITHIN, |
| 49 | + UNKNOWN |
| 50 | + }; |
| 51 | + |
| 52 | + QgsSpatialFilter(); |
| 53 | + QgsSpatialFilter( SPATIAL_TYPE st, QgsGeometry* geom ); |
| 54 | + ~QgsSpatialFilter(); |
| 55 | + |
| 56 | + /**Evaluates a feature against the filter. |
| 57 | + @return true if the filter applies for the feature*/ |
| 58 | + bool evaluate( const QgsFeature& f ) const; |
| 59 | + |
| 60 | + //setters and getters |
| 61 | + SPATIAL_TYPE spatialType() const {return mSpatialType;} |
| 62 | + void setSpatialType( SPATIAL_TYPE t ) {mSpatialType = t;} |
| 63 | + |
| 64 | + //setters and getters |
| 65 | + QgsGeometry* geometry() const {return mGeom;} |
| 66 | + void setGeometry( QgsGeometry* g ) {mGeom = g;} |
| 67 | + |
| 68 | + private: |
| 69 | + SPATIAL_TYPE mSpatialType; |
| 70 | + QgsGeometry* mGeom; |
| 71 | +}; |
| 72 | + |
| 73 | +#endif //QGSSPATIALFILTER_H |
0 commit comments