Skip to content

Commit

Permalink
[Server][WFS] Use editor widget setup for Range fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rldhont committed Sep 26, 2018
1 parent 37c1e23 commit 68ba754
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/server/services/wfs/qgswfsdescribefeaturetype.cpp
Expand Up @@ -323,6 +323,24 @@ namespace QgsWfs
else
attElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "dateTime" ) );
}
else if ( setup.type() == QStringLiteral( "Range" ) )
{
const QVariantMap config = setup.config();
if ( config.contains( QStringLiteral( "Precision" ) ) )
{
// if precision in range config is not the same as the attributePrec
// we need to update type
bool ok;
int configPrec( config[ QStringLiteral( "Precision" ) ].toInt( &ok ) );
if ( ok && configPrec != field.precision() )
{
if ( configPrec == 0 )
attElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "integer" ) );
else
attElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "decimal" ) );
}
}
}

sequenceElem.appendChild( attElem );

Expand Down
12 changes: 12 additions & 0 deletions src/server/services/wfs/qgswfsgetfeature.cpp
Expand Up @@ -1467,6 +1467,18 @@ namespace QgsWfs
return date.toString( fieldFormat );
}
}
else if ( setup.type() == QStringLiteral( "Range" ) )
{
const QVariantMap config = setup.config();
if ( config.contains( QStringLiteral( "Precision" ) ) )
{
// if precision is defined, use it
bool ok;
int precision( config[ QStringLiteral( "Precision" ) ].toInt( &ok ) );
if ( ok )
return QString::number( value.toDouble(), 'f', precision );
}
}

switch ( value.type() )
{
Expand Down

0 comments on commit 68ba754

Please sign in to comment.