-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SHPRestoreSHX(): add extra sanity checks #7778
Conversation
Thank you very much for this improvement! Is there a way to catch the SHPRestoreSHX() failure and display the emitted errors when using the "Repair shapefile" processing algorithm in QGIS https://github.com/qgis/QGIS/blob/master/src/analysis/processing/qgsalgorithmrepairshapefile.cpp#L81C6-L90? |
Perhaps calling CPLGetLastErrorType() + CPLGetLastErrorMsg(), but I haven't verified if there are not other subsequent errors that are emitted. Otherwise installing a custom error handler with CPLPushErrorHandlerEx() / CPLPopErrorHandler() is a way of catching all emitted errors, not just the last one |
I see another little issue here gdal/ogr/ogrsf_frmts/shape/shpopen.c Lines 685 to 698 in c92b22d
If SHAPE_RESTORE_SHX=YES, then SHPRestoreSHX is executed. If SHPRestoreSHX fails, then SHPOpenLLEx always returns SHPLIB_NULLPTR even if the layer, after the SHX restoration, could be read by SHPOpenLL.
(Why I see two times the same error?) I would also suggest add here gdal/ogr/ogrsf_frmts/shape/shpopen.c Lines 612 to 613 in c92b22d
a similar advice as the one at gdal/ogr/ogrsf_frmts/shape/shpopen.c Lines 417 to 418 in c92b22d
|
I see your point, but that seems appropriate to me, as a way to indicate something went wrong in the restoration.
probably because it first tries in update mode, and then in read-only mode
I'm a bit ambivalent about that. Suggesting SHAPE_RESTORE_SHX when there is no .shx is totally reasonable, but when the .shx exists and there is a disagreement with the .shp, this might be a corruption in the .shp itself. If you wanted to add a hint about SHAPE_RESTORE_SHX, words of caution should be added that it will override the existing .shx, which may prevent further forensic attempts, and people should probably backup the .shx before. |
No description provided.