@@ -455,8 +455,8 @@ void QgsWFSProjectParser::describeFeatureType( const QString& aTypeName, QDomEle
455455 const QgsFields& fields = layer->pendingFields ();
456456 for ( int idx = 0 ; idx < fields.count (); ++idx )
457457 {
458-
459- QString attributeName = fields. at ( idx ) .name ();
458+ const QgsField field = fields. at ( idx );
459+ QString attributeName = field .name ();
460460 // skip attribute if excluded from WFS publication
461461 if ( layerExcludedAttributes.contains ( attributeName ) )
462462 {
@@ -466,27 +466,57 @@ void QgsWFSProjectParser::describeFeatureType( const QString& aTypeName, QDomEle
466466 // xsd:element
467467 QDomElement attElem = doc.createElement ( " element" /* xsd:element*/ );
468468 attElem.setAttribute ( " name" , attributeName.replace ( " " , " _" ).replace ( mCleanTagNameRegExp , " " ) );
469- QVariant::Type attributeType = fields[idx] .type ();
469+ QVariant::Type attributeType = field .type ();
470470 if ( attributeType == QVariant::Int )
471- attElem.setAttribute ( " type" , " integer" );
471+ {
472+ attElem.setAttribute ( " type" , " int" );
473+ }
474+ else if ( attributeType == QVariant::UInt )
475+ {
476+ attElem.setAttribute ( " type" , " unsignedInt" );
477+ }
472478 else if ( attributeType == QVariant::LongLong )
479+ {
473480 attElem.setAttribute ( " type" , " long" );
481+ }
482+ else if ( attributeType == QVariant::ULongLong )
483+ {
484+ attElem.setAttribute ( " type" , " unsignedLong" );
485+ }
474486 else if ( attributeType == QVariant::Double )
475- attElem.setAttribute ( " type" , " double" );
487+ {
488+ // if the size is well known, it may be an integer
489+ // else a decimal
490+ // in sqlite the length is unknown but int type can be used
491+ if ( field.length () != 0 && field.precision () == 0 )
492+ attElem.setAttribute ( " type" , " integer" );
493+ else
494+ attElem.setAttribute ( " type" , " decimal" );
495+ }
476496 else if ( attributeType == QVariant::Bool )
497+ {
477498 attElem.setAttribute ( " type" , " boolean" );
499+ }
478500 else if ( attributeType == QVariant::Date )
501+ {
479502 attElem.setAttribute ( " type" , " date" );
503+ }
480504 else if ( attributeType == QVariant::Time )
505+ {
481506 attElem.setAttribute ( " type" , " time" );
507+ }
482508 else if ( attributeType == QVariant::DateTime )
509+ {
483510 attElem.setAttribute ( " type" , " dateTime" );
511+ }
484512 else
513+ {
485514 attElem.setAttribute ( " type" , " string" );
515+ }
486516
487517 sequenceElem.appendChild ( attElem );
488518
489- QString alias = fields. at ( idx ) .alias ();
519+ QString alias = field .alias ();
490520 if ( !alias.isEmpty () )
491521 {
492522 attElem.setAttribute ( " alias" , alias );
0 commit comments