Skip to content

Commit

Permalink
User friendly display string for geom column
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Nov 19, 2021
1 parent e3fa91b commit c5ac87a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/qgsfield.cpp
Expand Up @@ -19,6 +19,7 @@
#include "qgis.h"
#include "qgsapplication.h"
#include "qgssettings.h"
#include "qgsreferencedgeometry.h"

#include <QDataStream>
#include <QIcon>
Expand Down Expand Up @@ -258,6 +259,15 @@ QString QgsField::displayString( const QVariant &v ) const
return QgsApplication::nullRepresentation();
}

if ( v.userType() == QMetaType::type( "QgsReferencedGeometry" ) )
{
QgsReferencedGeometry geom = qvariant_cast<QgsReferencedGeometry>( v );
if( geom.isEmpty() )
return QgsApplication::nullRepresentation();
else
return QStringLiteral( "%1 [%2]" ).arg( geom.asWkt(), geom.crs().userFriendlyIdentifier() );
}

// Special treatment for numeric types if group separator is set or decimalPoint is not a dot
if ( d->type == QVariant::Double )
{
Expand Down

0 comments on commit c5ac87a

Please sign in to comment.