Vector-Tiles-Reader-QGIS-Plugin
Vector-Tiles-Reader-QGIS-Plugin copied to clipboard
GL style parse failure
Might be specific to QGIS3 (EDIT: no, same error with QGIS2).
I'm getting this error when trying to use a published GL style for OS ZoomStack.
Path: C:/Users/tchadwin/Desktop/OS-Open-Zoomstack.mbtiles (downloaded from https://www.ordnancesurvey.co.uk/business-and-government/products/os-open-zoomstack.html)
GL Style JSON URL: https://raw.githubusercontent.com/OrdnanceSurvey/OS-Open-Zoomstack-Stylesheets/master/Vector%20Tiles/Mapbox%20GL%20Styles/OS%20Outdoor.json
[2018-07-23 10:10:25,545] [MainThread ] [ERROR ] Style generation failed: (<class 'AttributeError'>, AttributeError("'list' object has no attribute 'startswith'",), <traceback object at 0x000000000E4A0948>), Traceback (most recent call last):
File "C:/Users/tchadwin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vector_tiles_reader\vtr_plugin.py", line 421, in _create_styles
core.generate_styles(data, output_directory, web_request_executor=self._load_style_data)
File "C:\Users\tchadwin\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\vector_tiles_reader\ext-libs\mapboxstyle2qgis\core\__init__.py", line 50, in generate_styles
styles = process(style_json)
File "C:\Users\tchadwin\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\vector_tiles_reader\ext-libs\mapboxstyle2qgis\core\__init__.py", line 111, in process
qgis_styles = get_styles(l)
File "C:\Users\tchadwin\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\vector_tiles_reader\ext-libs\mapboxstyle2qgis\core\__init__.py", line 299, in get_styles
all_values.extend(get_properties_by_zoom(layer, "paint/fill-color", is_color=True, default="rgba(0,0,0,0)"))
File "C:\Users\tchadwin\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\vector_tiles_reader\ext-libs\mapboxstyle2qgis\core\__init__.py", line 527, in get_properties_by_zoom
value = parse_color(value)
File "C:\Users\tchadwin\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\vector_tiles_reader\ext-libs\mapboxstyle2qgis\core\__init__.py", line 424, in parse_color
if color.startswith("#"):
AttributeError: 'list' object has no attribute 'startswith'
Traceback (most recent call last):
File "C:/Users/tchadwin/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\vector_tiles_reader\vtr_plugin.py", line 421, in _create_styles
core.generate_styles(data, output_directory, web_request_executor=self._load_style_data)
File "C:\Users\tchadwin\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\vector_tiles_reader\ext-libs\mapboxstyle2qgis\core\__init__.py", line 50, in generate_styles
styles = process(style_json)
File "C:\Users\tchadwin\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\vector_tiles_reader\ext-libs\mapboxstyle2qgis\core\__init__.py", line 111, in process
qgis_styles = get_styles(l)
File "C:\Users\tchadwin\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\vector_tiles_reader\ext-libs\mapboxstyle2qgis\core\__init__.py", line 299, in get_styles
all_values.extend(get_properties_by_zoom(layer, "paint/fill-color", is_color=True, default="rgba(0,0,0,0)"))
File "C:\Users\tchadwin\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\vector_tiles_reader\ext-libs\mapboxstyle2qgis\core\__init__.py", line 527, in get_properties_by_zoom
value = parse_color(value)
File "C:\Users\tchadwin\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\vector_tiles_reader\ext-libs\mapboxstyle2qgis\core\__init__.py", line 424, in parse_color
if color.startswith("#"):
AttributeError: 'list' object has no attribute 'startswith'
There's obviously something the style parser is not expecting. Probably just something missing in the implementation and looking at your stacktrace (thanks for that!), that's not a big thing to fix.
Sorry for the delay @tomchadwin
This is caused by a paint object like this:
"paint": {
"fill-color": [
"match",
[
"get",
"type"
],
"Air Transport",
"#e6e6e6",
"Education",
"#f7eaca",
"Medical Care",
"#f3d8e7",
"Road Transport",
"#f7f3ca",
"Water Transport",
"#d8e6f3",
"hsl(55, 74%, 88%)"
],
"fill-opacity": 0.6
}
Is the issue as broad as that match
is not implemented at all, or is it more specific than that?
Correct. I fear the implementation of the style converter is a neverending story and its architecture is far from optimal. On the other hand, a well working converter would be a really nice feature.
Somebody any ideas or hints regarding the architecture of such a piece of code?
cc: @sfkeller