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.09k stars 2.93k forks source link

Exception "osgeo::proj::io::FactoryException" is emmited when using the QgsMapCanvas class. #57553

Open loftyscholar opened 1 month ago

loftyscholar commented 1 month ago

What is the bug or the crash?

When I use the class like this "QgsMapCanvas* m_mapCanvas = new QgsMapCanvas;", I got many exceptions. According invetigation, it occured when calling the following function and process the proj string "+proj=longlat +a=10000 +no_defs +type=crs" "QgsEllipsoidUtils::EllipsoidParameters QgsEllipsoidUtils::ellipsoidParameters( const QString &e )" Actually, it is because there are several celestial bodies that match the 10000 radius in proj.db. How to resolve this problem?

Steps to reproduce the issue

QApplication a(argc, argv);
QString strAppDir = "./qgis";
QgsApplication::setPrefixPath(strAppDir, false);
QString strPluginDir = strAppDir + QString("/plugins/");    
QgsApplication::setPluginPath(strPluginDir);    
QString strPkgDir = strAppDir + QString("/share/data/");    
QgsApplication::setPkgDataPath(strPkgDir);
QString strProjDir = strAppDir + QString("/share/proj");
qputenv("PROJ_LIB", strProjDir.toStdString().c_str());   
/*loads providers*/
QgsApplication::initQgis();
spatialviz w;
QgsMapCanvas* m_mapCanvas = new QgsMapCanvas;
w.setCentralWidget(m_mapCanvas);

Versions

QGIS-final-3_36_0

Supported QGIS version

New profile

Additional context

No response

rouault commented 1 month ago

This is linked to https://github.com/OSGeo/PROJ/issues/4148

@loftyscholar Your bug description is not clear. Do those exceptions percolate through QGIS, or are they caught before in PROJ? Noramlly that should be just the later, and if so then https://github.com/OSGeo/PROJ/pull/4149 addresses the issue and there is no action on QGIS side

loftyscholar commented 1 month ago

This is linked to OSGeo/PROJ#4148

@loftyscholar Your bug description is not clear. Do those exceptions percolate through QGIS, or are they caught before in PROJ? Noramlly that should be just the later, and if so then OSGeo/PROJ#4149 addresses the issue and there is no action on QGIS side

Thanks again for your help. When I use the QgsMapcanvas object, the dialog "QgsProjectionSelectionTreeWidget" is always empty, i.e., no recently used srs or predefined crs, and I am wondering what cause this issue.