Bug report #18969

syncDB() and syncDatabase() fail to import WKTs from esri_extra.wkt and cubewerx_extra.wkt

Added by Andrea Giudiceandrea almost 6 years ago. Updated almost 6 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Projection Support
Affected QGIS version:3.1(master) Regression?:No
Operating System: Easy fix?:Yes
Pull Request or Patch supplied:Yes Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:26800

Description

QgsCoordinateReferenceSystem:: syncDb() and syncDatabase(), respectively for QGIS 2.18 and QGIS 3, through loadWkts(), fail to import 1 WKT from esri_extra.wkt (EPSG:102113) and 20 WKTs from cubewerx_extra.wkt (both from GDAL 2.2) during postintall (by crssync.exe in Windows).

This is due to an "empty" line present almost at the end of esri_extra.wkt, before the EPSG:102113 line, that was introduced accidentally with commit:21278c00304bb90c49180bb43cb074e8b4a4ccbf. At that time the code worked well also with that empty line, but later it was changed to fix some other bugs.

The bug lies in loadWkts(), that is used by syncDb() / syncDatabase() to load WKTs from epsg.wkts: it exits returning false if it finds an empty line during the for loop that reads the WKTs lines so it breaks the wkts reading process skipping the last line of esri_extra.wkt and all the lines in cubewerx_extra.wkt.

Obviously, we can fix this deleting the added empty line from esri_extra.wkt, but I think it would be better to fix the bug in loadWkts() slightly modifying this part of the for loop
https://github.com/qgis/QGIS/blob/release-2_18/src/core/qgscoordinatereferencesystem.cpp#L1603-L1610

      int pos = line.indexOf( ',' );
      if ( pos < 0 )
        return false;

      bool ok;
      int epsg = line.left( pos ).toInt( &ok );
      if ( !ok )
        return false;

like is in loadIDs()

https://github.com/qgis/QGIS/blob/release-2_18/src/core/qgscoordinatereferencesystem.cpp#L1644-L1651

      int pos = line.indexOf( ',' );
      if ( pos < 0 )
        continue;

      bool ok;
      int epsg = line.left( pos ).toInt( &ok );
      if ( !ok )
        continue;

because the new esri_extra.wkt and cubewerx_extra.wkt in GDAL 2.3 and above have empty lines between WKTs lines.

Associated revisions

Revision 7576ae10
Added by Jürgen Fischer almost 6 years ago

crssync:
  • also update coordinate system descriptions
  • retrieve descriptions of geocentric CRSes (fixes #18968)

History

#2 Updated by Jürgen Fischer almost 6 years ago

  • Resolution set to fixed/implemented
  • Status changed from Open to Closed

Fixed in 7576ae104

Also available in: Atom PDF