From d6919e9f07413a7d167a4c8d4c2d59d638e41b12 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Thu, 2 May 2024 19:26:22 +0200 Subject: [PATCH] Accept 2d box extent when estimating metadata Fixes GH-56541 --- src/providers/postgres/qgspostgresprovider.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/providers/postgres/qgspostgresprovider.cpp b/src/providers/postgres/qgspostgresprovider.cpp index b5b60612abab..94fba4df3798 100644 --- a/src/providers/postgres/qgspostgresprovider.cpp +++ b/src/providers/postgres/qgspostgresprovider.cpp @@ -3974,8 +3974,8 @@ QgsBox3D QgsPostgresProvider::extent3D() const { QgsDebugMsgLevel( QStringLiteral( "Got extents (%1) using: %2" ).arg( ext ).arg( sql ), 2 ); - const thread_local QRegularExpression rx( "\\((.+) (.+) (.+),(.+) (.+) (.+)\\)" ); - const QRegularExpressionMatch match = rx.match( ext ); + const thread_local QRegularExpression rx3d( "\\((.+) (.+) (.+),(.+) (.+) (.+)\\)" ); + const QRegularExpressionMatch match = rx3d.match( ext ); if ( match.hasMatch() ) { mLayerExtent.setXMinimum( match.captured( 1 ).toDouble() ); @@ -3993,7 +3993,19 @@ QgsBox3D QgsPostgresProvider::extent3D() const } else { - QgsMessageLog::logMessage( tr( "result of extents query invalid: %1" ).arg( ext ), tr( "PostGIS" ) ); + const thread_local QRegularExpression rx2d( "\\((.+) (.+),(.+) (.+)\\)" ); + const QRegularExpressionMatch match = rx2d.match( ext ); + if ( match.hasMatch() ) + { + mLayerExtent.setXMinimum( match.captured( 1 ).toDouble() ); + mLayerExtent.setYMinimum( match.captured( 2 ).toDouble() ); + mLayerExtent.setXMaximum( match.captured( 3 ).toDouble() ); + mLayerExtent.setYMaximum( match.captured( 4 ).toDouble() ); + } + else + { + QgsMessageLog::logMessage( tr( "result of extents query invalid: %1" ).arg( ext ), tr( "PostGIS" ) ); + } } }