Skip to content
Permalink
Browse files
Update the expression geomFromGML2 to geomFromGML
Like we simplified the QgsOgcUtils class, I simplify the expression with
renamed geomFromGML2 to geomFromGML.
This update gives me the ability to debugging geometryFromGML with
Envelope element.
  • Loading branch information
rldhont committed Mar 15, 2013
1 parent 1e30eb0 commit 3b9c688b645dc04dc6f99d03fdfebe49101cf781
@@ -770,7 +770,7 @@ static QVariant fcnGeomFromWKT( const QVariantList& values, QgsFeature*, QgsExpr
else
return QVariant();
}
static QVariant fcnGeomFromGML2( const QVariantList& values, QgsFeature*, QgsExpression* parent )
static QVariant fcnGeomFromGML( const QVariantList& values, QgsFeature*, QgsExpression* parent )
{
QString gml = getStringValue( values.at( 0 ), parent );
QgsGeometry* geom = QgsOgcUtils::geometryFromGML( gml );
@@ -1087,7 +1087,7 @@ const QList<QgsExpression::Function*> &QgsExpression::Functions()
<< 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( "geomFromGML", 1, fcnGeomFromGML, QObject::tr( "Geometry" ) )
<< new StaticFunction( "bbox", 2, fcnBbox, QObject::tr( "Geometry" ) )
<< new StaticFunction( "disjoint", 2, fcnDisjoint, QObject::tr( "Geometry" ) )
<< new StaticFunction( "intersects", 2, fcnIntersects, QObject::tr( "Geometry" ) )
@@ -942,7 +942,7 @@ QgsRectangle QgsOgcUtils::rectangleFromGMLEnvelope( const QDomNode& envelopeNode
if ( !conversionSuccess )
return rect;

elem = lowerCornerList.at( 0 ).toElement();
elem = upperCornerList.at( 0 ).toElement();
if ( elem.hasAttribute( "srsDimension" ) )
{
srsDimension = elem.attribute( "srsDimension" ).toInt( &conversionSuccess );
@@ -1605,7 +1605,7 @@ QgsExpression::NodeFunction* QgsOgcUtils::nodeSpatialOperatorFromOgcFilter( QDom

QgsExpression::NodeList *opArgs = new QgsExpression::NodeList();
opArgs->append( new QgsExpression::NodeFunction( QgsExpression::functionIndex( "$geometry" ), new QgsExpression::NodeList() ) );
opArgs->append( new QgsExpression::NodeFunction( QgsExpression::functionIndex( "geomFromGML2" ), gml2Args ) );
opArgs->append( new QgsExpression::NodeFunction( QgsExpression::functionIndex( "geomFromGML" ), gml2Args ) );

return new QgsExpression::NodeFunction( opIdx, opArgs );
}
@@ -2110,20 +2110,20 @@ QDomElement QgsOgcUtils::expressionFunctionToOgcFilter( const QgsExpression::Nod
otherGeomElem = QgsOgcUtils::geometryToGML( geom, doc );
delete geom;
}
else if ( otherFnDef->name() == "geomFromGML2" )
else if ( otherFnDef->name() == "geomFromGML" )
{
QgsExpression::Node* firstFnArg = otherFn->args()->list()[0];
if ( firstFnArg->nodeType() != QgsExpression::ntLiteral )
{
errorMessage = "geomFromGML2: argument must be string literal";
errorMessage = "geomFromGML: argument must be string literal";
return QDomElement();
}

QDomDocument geomDoc;
QString gml = static_cast<const QgsExpression::NodeLiteral*>( firstFnArg )->value().toString();
if ( !geomDoc.setContent( gml, true ) )
{
errorMessage = "geomFromGML2: unable to parse XML";
errorMessage = "geomFromGML: unable to parse XML";
return QDomElement();
}

@@ -571,18 +571,18 @@ class TestQgsExpression: public QObject
QTest::newRow( "geomFromWKT Polygon" ) << "geomFromWKT('" + QgsGeometry::fromPolygon( polygon )->exportToWkt() + "')" << ( void* ) QgsGeometry::fromPolygon( polygon ) << false;

// GML Point
QTest::newRow( "GML Point (coordinates)" ) << "geomFromGML2('<gml:Point><gml:coordinates>123,456</gml:coordinates></gml:Point>')" << ( void * ) QgsGeometry::fromPoint( point ) << false;
QTest::newRow( "GML Point (coordinates)" ) << "geomFromGML('<gml:Point><gml:coordinates>123,456</gml:coordinates></gml:Point>')" << ( void * ) QgsGeometry::fromPoint( point ) << false;
// gml:pos if from GML3
//QTest::newRow( "GML Point (pos)" ) << "geomFromGML2('<gml:Point srsName=\"foo\"><gml:pos srsDimension=\"2\">123 456</gml:pos></gml:Point>')" << ( void * ) QgsGeometry::fromPoint( point ) << false;
QTest::newRow( "GML Point (pos)" ) << "geomFromGML('<gml:Point srsName=\"foo\"><gml:pos srsDimension=\"2\">123 456</gml:pos></gml:Point>')" << ( void * ) QgsGeometry::fromPoint( point ) << false;

// GML Box
QgsRectangle rect( 135.2239, 34.4879, 135.8578, 34.8471 );
QTest::newRow( "GML Box" ) << "geomFromGML2('<gml:Box srsName=\"foo\"><gml:coordinates>135.2239,34.4879 135.8578,34.8471</gml:coordinates></gml:Box>')" << ( void * ) QgsGeometry::fromRect( rect ) << false;
QTest::newRow( "GML Box" ) << "geomFromGML('<gml:Box srsName=\"foo\"><gml:coordinates>135.2239,34.4879 135.8578,34.8471</gml:coordinates></gml:Box>')" << ( void * ) QgsGeometry::fromRect( rect ) << false;
// Envelope is from GML3 ?
//QTest::newRow( "GML Envelope" ) << "geomFromGML2('<gml:Envelope>"
// "<gml:lowerCorner>135.2239 34.4879</gml:lowerCorner>"
// "<gml:upperCorner>135.8578 34.8471</gml:upperCorner>"
// "</gml:Envelope>')" << ( void * ) QgsGeometry::fromRect( rect ) << false;
QTest::newRow( "GML Envelope" ) << "geomFromGML('<gml:Envelope>"
"<gml:lowerCorner>135.2239 34.4879</gml:lowerCorner>"
"<gml:upperCorner>135.8578 34.8471</gml:upperCorner>"
"</gml:Envelope>')" << ( void * ) QgsGeometry::fromRect( rect ) << false;
}

void eval_geometry_constructor()
@@ -172,12 +172,12 @@ void TestQgsOgcUtils::testExpressionFromOgcFilter_data()
"</Filter>" )
<< QString( "FIRST_NAME IS NULL" );

QTest::newRow( "bbox" ) << QString(
QTest::newRow( "bbox with GML2 Box" ) << QString(
"<Filter>"
"<BBOX><PropertyName>Name>NAME</PropertyName><gml:Box srsName='foo'>"
"<gml:coordinates>135.2239,34.4879 135.8578,34.8471</gml:coordinates></gml:Box></BBOX>"
"</Filter>" )
<< QString( "bbox($geometry, geomFromGML2('<Box srsName=\"foo\"><coordinates>135.2239,34.4879 135.8578,34.8471</coordinates></Box>'))" );
<< QString( "bbox($geometry, geomFromGML('<Box srsName=\"foo\"><coordinates>135.2239,34.4879 135.8578,34.8471</coordinates></Box>'))" );

QTest::newRow( "Intersects" ) << QString(
"<Filter>"
@@ -188,7 +188,7 @@ void TestQgsOgcUtils::testExpressionFromOgcFilter_data()
"</gml:Point>"
"</Intersects>"
"</Filter>" )
<< QString( "intersects($geometry, geomFromGML2('<Point><coordinates>123,456</coordinates></Point>'))" );
<< QString( "intersects($geometry, geomFromGML('<Point><coordinates>123,456</coordinates></Point>'))" );
}

void TestQgsOgcUtils::testExpressionFromOgcFilter()
@@ -319,7 +319,7 @@ void TestQgsOgcUtils::testExpressionToOgcFilter_data()
"</ogc:Intersects>"
"</ogc:Filter>" );

QTest::newRow( "contains + gml" ) << QString( "contains($geometry, geomFromGML2('<Point><coordinates cs=\",\" ts=\" \">5.0,6.0</coordinates></Point>'))" ) << QString(
QTest::newRow( "contains + gml" ) << QString( "contains($geometry, geomFromGML('<Point><coordinates cs=\",\" ts=\" \">5.0,6.0</coordinates></Point>'))" ) << QString(
"<ogc:Filter>"
"<ogc:Contains>"
"<ogc:PropertyName>geometry</ogc:PropertyName>"
@@ -328,7 +328,9 @@ void TestQgsOgcUtils::testExpressionToOgcFilter_data()
"</ogc:Filter>" );

/*
QTest::newRow( "bbox" ) << QString( "bbox(13.0983, )") << QString(
QTest::newRow( "bbox with GML3 Envelope" )
<< QString( "bbox($geometry, geomFromGML('<gml:Envelope><gml:lowerCorner>13.0983 31.5899</gml:lowerCorner><gml:upperCorner>35.5472 42.8143</gml:upperCorner></gml:Envelope>'))" )
<< QString(
"<ogc:Filter>"
"<ogc:BBOX>"
"<ogc:PropertyName>Geometry</ogc:PropertyName>"

0 comments on commit 3b9c688

Please sign in to comment.