Skip to content
Permalink
Browse files

wfs server: fix multilinestring parsing

  • Loading branch information
jef-n committed Jul 14, 2013
1 parent b7bdb4c commit 6d48f11e571546a0ae4b0dba4eafe9147553e55e
@@ -159,12 +159,12 @@ void QgsFeature::setGeometryAndOwnership( unsigned char *geom, size_t length )
setGeometry( g );
}

void QgsFeature::setFields( const QgsFields* fields, bool initAttributes )
void QgsFeature::setFields( const QgsFields* fields, bool init )
{
mFields = fields;
if ( initAttributes )
if ( init )
{
this->initAttributes( fields->count() );
initAttributes( fields->count() );
}
}

@@ -450,7 +450,7 @@ QgsGeometry* QgsOgcUtils::geometryFromGMLMultiLineString( const QDomElement& geo
{
for ( int i = 0; i < lineStringMemberList.size(); ++i )
{
QDomNodeList lineStringNodeList = geometryElement.elementsByTagNameNS( GML_NAMESPACE, "LineString" );
QDomNodeList lineStringNodeList = lineStringMemberList.at( i ).toElement().elementsByTagNameNS( GML_NAMESPACE, "LineString" );
if ( lineStringNodeList.size() < 1 )
{
return 0;
@@ -1423,9 +1423,11 @@ QDomDocument QgsWFSServer::transaction( const QString& requestBody )
QDomNodeList featNodes = actionElem.childNodes();
for ( int l = 0; l < featNodes.count(); l++ )
{
// Create feature for this layer
QgsFeature* f = new QgsFeature();
// Add the feature to the layer
// and store it to put it's Feature Id in the response
inFeatList << QgsFeature( fields );

// Create feature for this layer
QDomElement featureElem = featNodes.at( l ).toElement();

QDomNode currentAttributeChild = featureElem.firstChild();
@@ -1447,23 +1449,21 @@ QDomDocument QgsWFSServer::transaction( const QString& requestBody )
const QgsField& field = fields[fieldMapIt.value()];
QString attrValue = currentAttributeElement.text();
int attrType = field.type();
if ( attrType == 2 )
f->setAttribute( fieldMapIt.value(), attrValue.toInt() );
else if ( attrType == 6 )
f->setAttribute( fieldMapIt.value(), attrValue.toDouble() );
QgsDebugMsg( QString( "attr: name=%1 idx=%2 value=%3" ).arg( attrName ).arg( fieldMapIt.value() ).arg( attrValue ) );
if ( attrType == QVariant::Int )
inFeatList.last().setAttribute( fieldMapIt.value(), attrValue.toInt() );
else if ( attrType == QVariant::Double )
inFeatList.last().setAttribute( fieldMapIt.value(), attrValue.toDouble() );
else
f->setAttribute( fieldMapIt.value(), attrValue );
inFeatList.last().setAttribute( fieldMapIt.value(), attrValue );
}
else //a geometry attribute
{
f->setGeometry( QgsOgcUtils::geometryFromGML( currentAttributeElement ) );
inFeatList.last().setGeometry( QgsOgcUtils::geometryFromGML( currentAttributeElement ) );
}
}
currentAttributeChild = currentAttributeChild.nextSibling();
}
// Add the feature to th layer
// and store it to put it's Feature Id in the response
inFeatList.append( *f );
}
}
}
@@ -2190,8 +2190,8 @@ bool QgsPostgresProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
result = mConnectionRO->PQexecPrepared( "getid", params );
if ( result.PQresultStatus() != PGRES_TUPLES_OK )
{
QgsDebugMsg( QString( "Exception thrown due to PQexecPrepared of 'getid' returning != PGRES_COMMAND_OK (%1 != expected %2)" )
.arg( result.PQresultStatus() ).arg( PGRES_COMMAND_OK ) );
QgsDebugMsg( QString( "Exception thrown due to PQexecPrepared of 'getid' returning != PGRES_TUPLES_OK (%1 != expected %2)" )
.arg( result.PQresultStatus() ).arg( PGRES_TUPLES_OK ) );
throw PGException( result );
}
// TODO: watch out for NULL , handle somehow
@@ -2207,7 +2207,7 @@ bool QgsPostgresProvider::changeGeometryValues( QgsGeometryMap & geometry_map )
int expected_status = ( mSpatialColType == sctTopoGeometry ) ? PGRES_TUPLES_OK : PGRES_COMMAND_OK;
if ( result.PQresultStatus() != expected_status )
{
QgsDebugMsg( QString( "Exception thrown due to PQexecPrepared of 'getid' returning != PGRES_COMMAND_OK (%1 != expected %2)" )
QgsDebugMsg( QString( "Exception thrown due to PQexecPrepared of 'updatefeatures' returning %1 != expected %2" )
.arg( result.PQresultStatus() ).arg( expected_status ) );
throw PGException( result );
}
@@ -1651,7 +1651,7 @@ void QgsWFSProvider::handleException( const QDomDocument& serverResponse )
QDomElement exceptionElem = serverResponse.documentElement();
if ( exceptionElem.isNull() )
{
pushError( QObject::tr( "empty response" ).arg( exceptionElem.tagName() ) );
pushError( QObject::tr( "empty response" ) );
return;
}

0 comments on commit 6d48f11

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