Skip to content

Commit

Permalink
wfs server: fix multilinestring parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jul 14, 2013
1 parent b7bdb4c commit 6d48f11
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/core/qgsfeature.cpp
Expand Up @@ -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() );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsogcutils.cpp
Expand Up @@ -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;
Expand Down
22 changes: 11 additions & 11 deletions src/mapserver/qgswfsserver.cpp
Expand Up @@ -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();
Expand All @@ -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 );
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -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
Expand All @@ -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 );
}
Expand Down
2 changes: 1 addition & 1 deletion src/providers/wfs/qgswfsprovider.cpp
Expand Up @@ -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;
}

Expand Down

0 comments on commit 6d48f11

Please sign in to comment.