mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
First test with Qvariant QgsGeometry*
This commit is contained in:
parent
4ca2160e56
commit
2b31660d1b
@ -757,6 +757,37 @@ static QVariant fcnYat( const QVariantList& values, QgsFeature* f, QgsExpression
|
||||
else
|
||||
return QVariant();
|
||||
}
|
||||
static QVariant fcnGeometry( const QVariantList& , QgsFeature* f, QgsExpression* )
|
||||
{
|
||||
QgsGeometry* geom = f->geometry();
|
||||
if ( geom )
|
||||
return QVariant::fromValue( geom );
|
||||
else
|
||||
return QVariant();
|
||||
}
|
||||
static QVariant fcnGeomFromWKT( const QVariantList& values, QgsFeature*, QgsExpression* parent )
|
||||
{
|
||||
QString wkt = getStringValue( values.at( 0 ), parent );
|
||||
QgsGeometry* geom = QgsGeometry::fromWkt( wkt );
|
||||
if ( geom )
|
||||
return QVariant::fromValue( geom );
|
||||
else
|
||||
return QVariant();
|
||||
}
|
||||
static QVariant fcnGeomFromGML2( const QVariantList& values, QgsFeature*, QgsExpression* parent )
|
||||
{
|
||||
QDomDocument doc;
|
||||
QString errorMsg;
|
||||
QString gml = getStringValue( values.at( 0 ), parent );
|
||||
if ( !doc.setContent( gml, true, &errorMsg ) )
|
||||
return QVariant();
|
||||
|
||||
QgsGeometry* geom = QgsGeometry::fromGML2( doc.documentElement() );
|
||||
if ( geom )
|
||||
return QVariant::fromValue( geom );
|
||||
else
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
static QVariant fcnGeomArea( const QVariantList& , QgsFeature* f, QgsExpression* parent )
|
||||
{
|
||||
@ -932,6 +963,9 @@ const QList<QgsExpression::Function*> &QgsExpression::Functions()
|
||||
<< new StaticFunction( "$perimeter", 0, fcnGeomPerimeter, QObject::tr( "Geometry" ), "", true )
|
||||
<< new StaticFunction( "$x", 0, fcnX, QObject::tr( "Geometry" ), "", true )
|
||||
<< new StaticFunction( "$y", 0, fcnY, QObject::tr( "Geometry" ), "" , true )
|
||||
<< new StaticFunction( "$geometry", 0, fcnGeometry, QObject::tr( "Geometry" ), "" , true )
|
||||
<< new StaticFunction( "GeomFromWKT", 1, fcnGeomFromWKT, QObject::tr( "Geometry" ) )
|
||||
<< new StaticFunction( "GeomFromGML2", 1, fcnGeomFromGML2, QObject::tr( "Geometry" ) )
|
||||
<< new StaticFunction( "$rownum", 0, fcnRowNumber, QObject::tr( "Record" ) )
|
||||
<< new StaticFunction( "$id", 0, fcnFeatureId, QObject::tr( "Record" ) )
|
||||
<< new StaticFunction( "$scale", 0, fcnScale, QObject::tr( "Record" ) )
|
||||
|
@ -434,7 +434,7 @@ class CORE_EXPORT QgsExpression
|
||||
{
|
||||
public:
|
||||
NodeSpatialOperator( SpatialOperator op, QgsGeometry* opGeom ) : mOp( op ), mOpGeometry( 0 ) { if ( opGeom ) mOpGeometry = opGeom; }
|
||||
~NodeSpatialOperator() { delete mOpGeometry; }
|
||||
~NodeSpatialOperator() { }
|
||||
|
||||
virtual bool prepare( QgsExpression* parent, const QgsFieldMap& fields );
|
||||
virtual QVariant eval( QgsExpression* parent, QgsFeature* f );
|
||||
@ -630,6 +630,7 @@ class CORE_EXPORT QgsExpression
|
||||
QgsDistanceArea* mCalc;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE( QgsExpression::Interval )
|
||||
Q_DECLARE_METATYPE( QgsExpression::Interval );
|
||||
Q_DECLARE_METATYPE( QgsGeometry * );
|
||||
|
||||
#endif // QGSEXPRESSION_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user