Пример #1
0
    void eval_geometry_constructor()
    {
      QFETCH( QString, string );
      QFETCH( void*, geomptr );
      QFETCH( bool, evalError );

      QgsGeometry* geom = ( QgsGeometry* ) geomptr;

      QgsFeature f;
      f.setGeometry( geom );

      QgsExpression exp( string );
      QCOMPARE( exp.hasParserError(), false );
      QCOMPARE( exp.needsGeometry(), false );
      QVariant out = exp.evaluate( &f );
      QCOMPARE( exp.hasEvalError(), evalError );

      QCOMPARE( out.canConvert<QgsGeometry>(), true );
      QgsGeometry outGeom = out.value<QgsGeometry>();
      QCOMPARE( geom->equals( &outGeom ), true );
    }
Пример #2
-1
bool QgsSpatialFilter::evaluate( const QgsFeature& f ) const
{
  if ( !mGeom )
  {
    return true;
  }

  QgsGeometry* geom = ( new QgsFeature( f ) )->geometry();
  switch ( mSpatialType )
  {
    case BBOX:
      return geom->intersects( mGeom->boundingBox() );
      break;
    case CONTAINS:
      return geom->contains( mGeom );
      break;
    case CROSSES:
      return geom->crosses( mGeom );
      break;
    case DISJOINT:
      return geom->disjoint( mGeom );
      break;
    case EQUALS:
      return geom->equals( mGeom );
      break;
    case INTERSECTS:
      return geom->intersects( mGeom );
      break;
    case OVERLAPS:
      return geom->overlaps( mGeom );
      break;
    case TOUCHES:
      return geom->touches( mGeom );
      break;
    case WITHIN:
      return geom->within( mGeom );
      break;
    case UNKNOWN:
    default:
      break;
  }
  return false;
}