Skip to content

Commit 68ba754

Browse files
committed
[Server][WFS] Use editor widget setup for Range fields
1 parent 37c1e23 commit 68ba754

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/server/services/wfs/qgswfsdescribefeaturetype.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,24 @@ namespace QgsWfs
323323
else
324324
attElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "dateTime" ) );
325325
}
326+
else if ( setup.type() == QStringLiteral( "Range" ) )
327+
{
328+
const QVariantMap config = setup.config();
329+
if ( config.contains( QStringLiteral( "Precision" ) ) )
330+
{
331+
// if precision in range config is not the same as the attributePrec
332+
// we need to update type
333+
bool ok;
334+
int configPrec( config[ QStringLiteral( "Precision" ) ].toInt( &ok ) );
335+
if ( ok && configPrec != field.precision() )
336+
{
337+
if ( configPrec == 0 )
338+
attElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "integer" ) );
339+
else
340+
attElem.setAttribute( QStringLiteral( "type" ), QStringLiteral( "decimal" ) );
341+
}
342+
}
343+
}
326344

327345
sequenceElem.appendChild( attElem );
328346

src/server/services/wfs/qgswfsgetfeature.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,18 @@ namespace QgsWfs
14671467
return date.toString( fieldFormat );
14681468
}
14691469
}
1470+
else if ( setup.type() == QStringLiteral( "Range" ) )
1471+
{
1472+
const QVariantMap config = setup.config();
1473+
if ( config.contains( QStringLiteral( "Precision" ) ) )
1474+
{
1475+
// if precision is defined, use it
1476+
bool ok;
1477+
int precision( config[ QStringLiteral( "Precision" ) ].toInt( &ok ) );
1478+
if ( ok )
1479+
return QString::number( value.toDouble(), 'f', precision );
1480+
}
1481+
}
14701482

14711483
switch ( value.type() )
14721484
{

0 commit comments

Comments
 (0)