geostyler / geostyler-qgis-parser

GeoStyler Style Parser implementation for QGIS
https://geostyler.org
BSD 2-Clause "Simplified" License
18 stars 9 forks source link

Error when converting QML: Cannot read property 'forEach' of undefined #541

Open max-mapper opened 6 months ago

max-mapper commented 6 months ago

Bug

Describe the bug I receive this error:

$ node -v
v20.14.0
$ geostyler -v
v3.0.0
$ geostyler -s qgis -t mapbox -o calveg-ec-clipped.json calveg-ec-clipped.qml 
✖ Error during translation of file "calveg-ec-clipped.qml": TypeError: Cannot read properties of undefined (reading 'forEach')

To Reproduce

calveg-ec-clipped.zip

This QML file exported from QGIS using 3.36.3-Maidenhead

Also worth noting... if I export the same layer in QGIS to SLD and then convert SLD to Mapbox, it does not include the fill values. However, if I export from QGIS to SLD, then use geostyler to convert SLD to QML and then QML to Mapbox, it includes fill values. Hence this is why I am reporting this issue, it would be nice if QML worked without crashing. It would also be nice if QGIS exported SLD converted directly to Mapbox and included fill values

KaiVolland commented 6 months ago

Hey @max-mapper, thanks for the report. I'll add it to the codes-print board. Maybe someone will have the time to have a look at it.

geographika commented 5 months ago

This is the same issue as #455 and #540, with the development fix branch at https://github.com/geostyler/geostyler-qgis-parser/compare/master...OSHistory:geostyler-qgis-parser:readQGIS228

It looks like there were major changes to the (undocumented) QML structures from QGIS 3.28 onwards.

See https://github.com/qgis/QGIS/pull/45143 and https://github.com/qgis/QGIS/pull/40716

@geostyler/sprinters I think we should probably add a warning to the README.md that the parser only works with pre QGIS 3.28 versions until fixed.

slafayIGN commented 5 months ago

The QGIS version used to generatee the QML structure is located in the <qgis> markup. So it should be possible to make the parser behaviour change depending on it: