qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.52k stars 2.99k forks source link

3.36 PostGIS layers have no spatial extent #56541

Closed Komz0 closed 5 months ago

Komz0 commented 7 months ago

What is the bug or the crash?

Layers loaded from a PostgreSQL / PostGIS database have no spatial extent. Extent in Information tab of layer is set to Null. Zoom to layer functionality throw this warning :
WARNING result of extents query invalid: BOX(144881.046875 200921.21875,505398.1875 515061.03125)

The issue is 3.36 specific ; the same layers works in 3.32 and 3.28. No issues with a Geopackage layer.

Steps to reproduce the issue

Load a layer from a PostGIS database.

Versions

QGIS version 3.36.0-Maidenhead QGIS code revision 09951dc0 Qt version 5.15.3 Python version 3.9.18 GDAL/OGR version 3.8.4 PROJ version 9.3.1 EPSG Registry database version v10.098 (2023-11-24) GEOS version 3.12.1-CAPI-1.18.1 SQLite version 3.41.1 PDAL version 2.6.0 PostgreSQL client version 16.1 SpatiaLite version 5.1.0 QWT version 6.1.6 QScintilla2 version 2.13.4 OS version Windows 10 Version 2009

Active Python plugins fms_cycles 0.1 sln_acquire 0.1 string_importer 0.1 db-style-manager 0.8 firstaid 3.1.0 HouseNumbering3 version 0.0.5 lizmap 4.2.2 pg_metadata 1.3.0 plugin_reloader 0.9.3 plume 1.1.1 processing_saga_nextgen 1.0.0 profiletool 4.2.6 qfieldsync v4.7.1 Qgis2threejs 2.7.3 qgis2web 3.18.2 QGISSortAndNumber-master 1.0 quick_map_services 0.19.34 StyleLoadSave 1.0 ViewshedAnalysis 1.8 db_manager 0.1.20 grassprovider 2.12.99 processing 2.12.99

Supported QGIS version

New profile

Additional context

PostgreSQL 15.3 PostGIS 3.3 USE_GEOS=1 USE_PROJ=1 USE_STATS=1

elpaso commented 7 months ago

I cannot reproduce on QGIS 3.6, can you attach a minimal SQL dump of a database table that shows the issue?

Komz0 commented 7 months ago

I tried to make a minimal SQL, but It doesn't occur with small dataset (limit seems around 1000 rows). Also, I noticed it only occur with the "Use estimated table Metadata" option activated.

tbnobody commented 7 months ago

I am facing the same issue. Could reproduce it as shown in the attached pdf

qgis_bugifx.pdf

PeterDrexel commented 7 months ago

the same here with QGIS 3.36, works fine in 3.34

Antoviscomi commented 7 months ago

in mine 3.36:

  1. PG layer

Schermata del 2024-03-21 09-57-07

  1. the same layer exported in local

Schermata del 2024-03-21 10-52-27

note the abnormal values in second screenshot

Antoviscomi commented 7 months ago

@elpaso in addition, I'm not able to clean a spatial filter on source properties as you can see in screencast

Video del 21-03-2024 11:22:01.webm

I dont know it's related but this behaviour came out only in Spatially filtered layers

Filtered

while in non filtered layer

nonFiltered

Antoviscomi commented 7 months ago

this seems very very strange (it's a local layer so I think this issue it's not only related to PG layers)

Video del 21-03-2024 13:07:13.webm

Antoviscomi commented 7 months ago

persists in 3.36.1-Maidenhead Revisione codice QGIS [3e589453264]

PeterDrexel commented 6 months ago

Very bad issue, for example zoom to extent does not work anymore.

github-actions[bot] commented 6 months ago

The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale". If you would like to continue with this issue, please provide any missing information or answer any open questions. If you could resolve the issue yourself meanwhile, please leave a note for future readers with the same problem and close the issue. In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this issue. If there is no further activity on this issue, it will be closed in a week.

PeterDrexel commented 6 months ago

Try to turn off “Use estimated table metadata” in the PostGIS Connection Options. This works for me in QG 3.36 und 3.37.

Antoviscomi commented 6 months ago

@PeterDrexel it's not true for me, the "Estimated metadata" box was unflagged as you can see below but no spatial extension

Schermata del 2024-04-23 13-48-08

but no spatial extension as you can see in below

Schermata del 2024-04-23 13-52-09

strk commented 5 months ago

I have the same problem with QGIS versio 3.37.0-Master code revision 4abc2054771

Both with using estimated or full metadata. I always get the WARNING: WARNING result of extents query invalid: BOX(379609.6875 5246217,430990.375 5292334.5)

What makes that box invalid ?

strk commented 5 months ago

According to code what makes the result of extent query invalid is not matching this regexp: const thread_local QRegularExpression rx( "\\((.+) (.+) (.+),(.+) (.+) (.+)\\)" );

strk commented 5 months ago

Removing the duplicated backslashes fixes the issue for me, PR coming next.

strk commented 5 months ago

Sorry, I'm taking it back, it's not the backslashes but the number of ordinates expected, why are 3 ordinates expected instead of 2 ?

strk commented 5 months ago

Got it: the code was broken by d759a90da6fed3b8a6f7d5f0671de7c00f12f667 adding support for 3D extents but forgetting to handle the estimated metadata code path.

strk commented 5 months ago

@benoitdm-oslandia want to deal with this ?

strk commented 5 months ago

My version of the fix: https://github.com/qgis/QGIS/pull/57323 tests from original reporters are welcome

benoitdm-oslandia commented 5 months ago

@strk I will have a look asap

PeterDrexel commented 4 months ago

Sorry for the late feedback: Its fine now again, thank you very much for fixing it! Peter