GeoCat / qgis-bridge-plugin

GeoCat Bridge is a plugin for QGIS that can be used to publish geospatial (meta)data to the cloud.
https://geocat.github.io/qgis-bridge-plugin/
GNU General Public License v3.0
36 stars 17 forks source link

scaledenominator throws TypeError: argument of type 'float' is not iterable #61

Closed pvgenuchten closed 4 years ago

pvgenuchten commented 4 years ago

if setting a scaledenominator on a style (rule-based style, rule has scaledenominator set).

image

i get this error (setting the locale to en_us didn't change the behaviour):

TypeError: cannot serialize 100000.0 (type float) 
Traceback (most recent call last):
  File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/xml/etree/ElementTree.py", line 1067, in _escape_cdata
    if "&" in text:
TypeError: argument of type 'float' is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/geocat/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/geocatbridge/ui/multistylerdialog.py", line 49, in updateLayer
    self.updateForCurrentLayer()
  File "/Users/geocat/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/geocatbridge/ui/multistylerdialog.py", line 59, in updateForCurrentLayer
    sld, _, sldWarnings = layerStyleAsSld(layer)
  File "/Users/geocat/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/geocatbridge/libs/bridgestyle/bridgestyle/qgis/__init__.py", line 18, in layerStyleAsSld
    sldString, sldWarnings = sld.fromgeostyler.convert(geostyler)
  File "/Users/geocat/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/geocatbridge/libs/bridgestyle/bridgestyle/sld/fromgeostyler.py", line 38, in convert
    sldstring = ElementTree.tostring(root, encoding='utf8', method='xml').decode()
  File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/xml/etree/ElementTree.py", line 1136, in tostring
    short_empty_elements=short_empty_elements)
  File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/xml/etree/ElementTree.py", line 777, in write
    short_empty_elements=short_empty_elements)
  File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/xml/etree/ElementTree.py", line 942, in _serialize_xml
    short_empty_elements=short_empty_elements)
  File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/xml/etree/ElementTree.py", line 942, in _serialize_xml
    short_empty_elements=short_empty_elements)
  File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/xml/etree/ElementTree.py", line 942, in _serialize_xml
    short_empty_elements=short_empty_elements)
  [Previous line repeated 2 more times]
  File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/xml/etree/ElementTree.py", line 939, in _serialize_xml
    write(_escape_cdata(text))
  File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/xml/etree/ElementTree.py", line 1075, in _escape_cdata
    _raise_serialization_error(text)
  File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/xml/etree/ElementTree.py", line 1058, in _raise_serialization_error
    "cannot serialize %r (type %s)" % (text, type(text).__name__)
TypeError: cannot serialize 100000.0 (type float)
pvgenuchten commented 4 years ago

scaledenominator.qgz.zip

pvgenuchten commented 4 years ago

This problem may refer to this answer (it talks about the same _escape_cdata element) https://stackoverflow.com/a/53374903 Suggestion is to use lxml.objectify in stead.

pvgenuchten commented 4 years ago

got a similar issue with nonetype

image

Traceback (most recent call last): File "/Applications/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python3.7/xml/etree/ElementTree.py", line 1080, in _escape_attrib if "&" in text: TypeError: argument of type 'NoneType' is not iterable

nonetype.qgz.zip

pvgenuchten commented 4 years ago

resolved by https://github.com/GeoCat/bridge-style/pull/40