FieldStudiesCouncil / QGIS-Biological-Recording-Tools

QGIS plugin for biological recorders. Created with the FSC Tomorrow's Biodiversity project.
GNU General Public License v3.0
10 stars 4 forks source link

Error generating image from composer with QGIS 3.16 #57

Closed burkmarr closed 2 years ago

burkmarr commented 2 years ago

From https://forum.fscbiodiversity.uk/t/not-exporting-composer/192:

Not sure if this is just me but i have tried the plugin on 3.8 and 3.16 with the latest update and getting the same issue. When trying to batch export to using composer image i receive a rather useless QGIS warning " Error : Image generation error: " the plugin runs through each layer but no images are generated.

I have tried simplifying the composer so it is just a map and i receive the same issue.

Additionally while sifting the log i found the following message which i suspect relates to producing shapefiles(?), though this is still working;

WARNING warning:C***/python/plugins\TomBio\biorecdialog.py:1201: DeprecationWarning: QgsVectorFileWriter.writeAsVectorFormat() is deprecated error = QgsVectorFileWriter.writeAsVectorFormat(layer.getVectorLayer(), filePath, “utf-8”, outCRS, formatArg)

burkmarr commented 2 years ago

I've reproduced this is 3.16 and 3.6

benj-d commented 2 years ago

The FSC forum appears to be down so just to follow up on this. I've had a play with the code and it looks like the composer output function is linked explicitly to the metadata checkbox. Checking the metadata box produces the output as expected but when not checked the try doesn't fire so it goes direct to the except without error. It's not trying the try...?

Not entirely sure what the metadata checkbox is doing and there appears to be no good reason not to have it checked so I'm leaving this for now and sticking to 'ensure metadata box is checked'!

Also, the unrelated warning regarding depreciated writeAsVectorFormat()is now writeAsVectorFormatV2

charlesroper commented 2 years ago

The FSC forum appears to be down

Should be back again now, Ben. Thanks for the report. I'll leave other bits for Rich.

burkmarr commented 2 years ago

Thanks for the extra info Ben. I will try to take a look at this soon.

benj-d commented 2 years ago

The FSC forum appears to be down

Should be back again now, Ben. Thanks for the report. I'll leave other bits for Rich.

Cheers @charlesroper i did also report this direct to FSC so apologies if you got it twice!

benj-d commented 2 years ago

Thanks for the extra info Ben. I will try to take a look at this soon.

@burkmarr as a temporary change i have made the checkbox default 2 checked. Generally i doubt people will change it so may be a quick fix.

I also looked a bit more into depreciated writeAsVectorFormat() both this and V2 are actually depreciated V3 is the current for 3.23 and on. So this is probably best left as is. I've implemented V2 (changes also work with V3) with comments here: https://github.com/benj-d/QGIS-Biological-Recording-Tools/blob/b3ad0f21294da955b33472028739934770cb286e/biorecdialog.py#L1208

burkmarr commented 2 years ago

Initial reported bug fixed in version 3.1.4. Unrelated deprecated code also replaced. (Thanks for your input @benj-d.)