Skip to content
Permalink
Browse files

#6535 Support WFS Post GetFeature Request in QGIS-Server

  • Loading branch information
rldhont committed Oct 26, 2012
1 parent 1fdaa04 commit b9f631f77b6c0910f87cf9553479fc8e0385eb42
@@ -536,14 +536,24 @@ QgsGeometry* QgsGeometry::fromRect( const QgsRectangle& rect )
static const QString GML_NAMESPACE = "http://www.opengis.net/gml";
QgsGeometry* QgsGeometry::fromGML2( const QDomNode& geometryNode )
{
QDomNode geometryChild = geometryNode.firstChild();
if ( geometryChild.isNull() )
{
return 0;
}
QgsGeometry* g = new QgsGeometry();
QDomElement geometryTypeElement = geometryChild.toElement();
QDomElement geometryTypeElement = geometryNode.toElement();
QString geomType = geometryTypeElement.tagName();

if ( !( geomType == "Point" || geomType == "LineString" || geomType == "Polygon" || geomType == "MultiPoint" || geomType == "MultiLineString" || geomType == "MultiPolygon") )
{
QDomNode geometryChild = geometryNode.firstChild();
if ( geometryChild.isNull() )
{
return 0;
}
geometryTypeElement = geometryChild.toElement();
geomType = geometryTypeElement.tagName();
}

if ( !( geomType == "Point" || geomType == "LineString" || geomType == "Polygon" || geomType == "MultiPoint" || geomType == "MultiLineString" || geomType == "MultiPolygon") )
return 0;

if ( geomType == "Point" )
{
g->setFromGML2Point( geometryTypeElement );
@@ -34,6 +34,7 @@ SET ( qgis_mapserv_SRCS
qgsbetweenfilter.cpp
qgscomparisonfilter.cpp
qgslogicalfilter.cpp
qgsspatialfilter.cpp
qgsftptransaction.cpp
qgsmslayerbuilder.cpp
qgshostedvdsbuilder.cpp
@@ -19,6 +19,7 @@
#include "qgsbetweenfilter.h"
#include "qgscomparisonfilter.h"
#include "qgslogicalfilter.h"
#include "qgsspatialfilter.h"
#include "qgsvectordataprovider.h"
#include <QDomElement>
#include <QStringList>
@@ -56,7 +57,8 @@ QgsFilter* QgsFilter::createFilterFromXml( const QDomElement& filterElem, QgsVec
}

//Name of the element indicates the type of filter
QString filterName = filterElem.localName();
//using tagName and to upper for interoperability
QString filterName = filterElem.tagName().toUpper();

if ( filterName == "AND" || filterName == "OR" || filterName == "NOT" )
{
@@ -91,6 +93,112 @@ QgsFilter* QgsFilter::createFilterFromXml( const QDomElement& filterElem, QgsVec
}
delete subFilter1; delete subFilter2; return 0;
}
// if the filter is spatial
if ( filterName == "BBOX" || filterName == "CONTAINS" || filterName == "CROSSES" || filterName == "DISJOINT" || filterName == "EQUALS" || filterName == "INTERSECTS" || filterName == "OVERLAPS" || filterName == "TOUCHES" || filterName == "WITHIN" )
{
QgsGeometry* geom;

QDomNodeList bNodes = filterElem.elementsByTagName( "Box" );
if ( bNodes.size() > 0 ) {
QDomElement bElem = bNodes.at( 0 ).toElement().firstChild().toElement();
QString coordSeparator = ",";
QString tupelSeparator = " ";
if ( bElem.hasAttribute( "cs" ) )
{
coordSeparator = bElem.attribute( "cs" );
}
if ( bElem.hasAttribute( "ts" ) )
{
tupelSeparator = bElem.attribute( "ts" );
}

QString bString = bElem.text();
bool conversionSuccess;
double minx = bString.section( tupelSeparator, 0, 0 ).section( coordSeparator, 0, 0 ).toDouble( &conversionSuccess );
double miny = bString.section( tupelSeparator, 0, 0 ).section( coordSeparator, 1, 1 ).toDouble( &conversionSuccess );
double maxx = bString.section( tupelSeparator, 1, 1 ).section( coordSeparator, 0, 0 ).toDouble( &conversionSuccess );
double maxy = bString.section( tupelSeparator, 1, 1 ).section( coordSeparator, 1, 1 ).toDouble( &conversionSuccess );
QgsRectangle* rect = new QgsRectangle( minx, miny, maxx, maxy );
geom = QgsGeometry::fromRect( *rect );
}

if ( !geom )
{
QDomNodeList gNodes = filterElem.elementsByTagName( "Point" );
if ( gNodes.size() > 0 ) {
QDomElement gElem = gNodes.at( 0 ).toElement();
geom = QgsGeometry::fromGML2( gElem );
}
}

if ( !geom )
{
QDomNodeList gNodes = filterElem.elementsByTagName( "LineString" );
if ( gNodes.size() > 0 ) {
QDomElement gElem = gNodes.at( 0 ).toElement();
geom = QgsGeometry::fromGML2( gElem );
}
}

if ( !geom )
{
QDomNodeList gNodes = filterElem.elementsByTagName( "Polygon" );
if ( gNodes.size() > 0 ) {
QDomElement gElem = gNodes.at( 0 ).toElement();
geom = QgsGeometry::fromGML2( gElem );
}
}

if ( !geom )
{
QDomNodeList gNodes = filterElem.elementsByTagName( "MultiPoint" );
if ( gNodes.size() > 0 ) {
QDomElement gElem = gNodes.at( 0 ).toElement();
geom = QgsGeometry::fromGML2( gElem );
}
}

if ( !geom )
{
QDomNodeList gNodes = filterElem.elementsByTagName( "MultiLineString" );
if ( gNodes.size() > 0 ) {
QDomElement gElem = gNodes.at( 0 ).toElement();
geom = QgsGeometry::fromGML2( gElem );
}
}

if ( !geom )
{
QDomNodeList gNodes = filterElem.elementsByTagName( "MultiPolygon" );
if ( gNodes.size() > 0 ) {
QDomElement gElem = gNodes.at( 0 ).toElement();
geom = QgsGeometry::fromGML2( gElem );
}
}

if ( !geom )
return 0;

if ( filterName == "BBOX" )
return new QgsSpatialFilter( QgsSpatialFilter::BBOX, geom );
if ( filterName == "CONTAINS" )
return new QgsSpatialFilter( QgsSpatialFilter::CONTAINS, geom );
if ( filterName == "CROSSES" )
return new QgsSpatialFilter( QgsSpatialFilter::CROSSES, geom );
if ( filterName == "DISJOINT" )
return new QgsSpatialFilter( QgsSpatialFilter::DISJOINT, geom );
if ( filterName == "EQUALS" )
return new QgsSpatialFilter( QgsSpatialFilter::EQUALS, geom );
if ( filterName == "INTERSECTS" )
return new QgsSpatialFilter( QgsSpatialFilter::INTERSECTS, geom );
if ( filterName == "OVERLAPS" )
return new QgsSpatialFilter( QgsSpatialFilter::OVERLAPS, geom );
if ( filterName == "TOUCHES" )
return new QgsSpatialFilter( QgsSpatialFilter::TOUCHES, geom );
if ( filterName == "WITHIN" )
return new QgsSpatialFilter( QgsSpatialFilter::WITHIN, geom );
return 0;
}

//assume it must be a comparison filter

@@ -153,33 +261,33 @@ QgsFilter* QgsFilter::createFilterFromXml( const QDomElement& filterElem, QgsVec
//now create the filter

//comparison filter?
if ( filterName == "PropertyIsEqualTo" )
if ( filterName == "PROPERTYISEQUALTO" )
{
return new QgsComparisonFilter( attributeIndex, QgsComparisonFilter::EQUAL, literalList.at( 0 ) );
}
else if ( filterName == "PropertyIsNotEqualTo" )
else if ( filterName == "PROPERTYISNOTEQUALTO" )
{
return new QgsComparisonFilter( attributeIndex, QgsComparisonFilter::NOT_EQUAL, literalList.at( 0 ) );
}
else if ( filterName == "PropertyIsLessThan" )
else if ( filterName == "PROPERTYISLESSTHAN" )
{
return new QgsComparisonFilter( attributeIndex, QgsComparisonFilter::LESSER, literalList.at( 0 ) );
}
else if ( filterName == "PropertyIsGreaterThan" )
else if ( filterName == "PROPERTYISGREATERTHAN" )
{
return new QgsComparisonFilter( attributeIndex, QgsComparisonFilter::GREATER, literalList.at( 0 ) );
}
else if ( filterName == "PropertyIsLessThanOrEqualTo" )
else if ( filterName == "PROPERTYISLESSTHANOREQUALTO" )
{
return new QgsComparisonFilter( attributeIndex, QgsComparisonFilter::LESSER_OR_EQUAL, literalList.at( 0 ) );
}
else if ( filterName == "PropertyIsGreaterThanOrEqualTo" )
else if ( filterName == "PROPERTYISGREATERTHANOREQUALTO" )
{
return new QgsComparisonFilter( attributeIndex, QgsComparisonFilter::GREATER_OR_EQUAL, literalList.at( 0 ) );
}

//between filter?
else if ( filterName == "PropertyIsBetween" )
else if ( filterName == "PROPERTYISBETWEEN" )
{
return new QgsBetweenFilter( attributeIndex, literalList.at( 0 ), literalList.at( 1 ) );
}
@@ -60,7 +60,7 @@ QMap<QString, QString> QgsPostRequestHandler::parseInput()
QDomElement docElem = doc.documentElement();
parameters.insert( "VERSION", docElem.attribute( "version" ) );
parameters.insert( "SERVICE", docElem.attribute( "service" ) );
parameters.insert( "REQUEST", docElem.localName() );
parameters.insert( "REQUEST", docElem.tagName() );
parameters.insert( "REQUEST_BODY", inputString );
}

0 comments on commit b9f631f

Please sign in to comment.
You can’t perform that action at this time.