Hello Charles.. Thanks a million it worked!! I used you script.
Best regards, Andreas Steiner Von: Charles Dixon-Paver <[email protected]> Gesendet: Dienstag, 5. Januar 2021 11:47 An: STEINER Andreas <[email protected]> Cc: [email protected] Betreff: [EXTERN]Re: [Qgis-user] Changing SVG Search Paths without GUI on Debian Buster | QGIS 3.10.12 Any number of things can go wrong with file paths, but QGIS allows you to embed SVG objects in project files to avoid these problems. If you can open the project on your windows environment, where the SVG file path is specified you should be able to use the drop down on the "Browse" menu and select the embed option, then specify the SVG file to include. I also previously wrote a script to automatically embed the svg symbols for all layers in a project if you have a lot of layers to update. Currently only supports single layer marker (so if you have complex symbology it may not work). You may be able to adapt it to your needs One issue is that the marker is embedded as a base64 string. This means if you have a complex SVG and use the same symbol on multiple layers, it may be a bit clunky especially when used on QGIS server. I still think investigating the file path issue is worth figuring out, but the embed method should help as a quickfix. """ Run from the python QGIS console to take existing svg paths and convert them to project-embedded symbol items. Currently only supports single symbol and rule style types. Doesn't cater for geometry builder elements or other advanced functions. """ import os import base64 def embedSymbol(symbol): try: layer_type = symbol.layerType() if layer_type == 'SvgMarker': svg_path = symbol.path() if svg_path[:7] == 'base64:': print('svg symbol already embedded') else: encoded_string = "" with open(svg_path, "rb") as svg: encoded_string = base64.b64encode(svg.read()) decoded_string = encoded_string.decode("utf-8") svg_content = 'base64:' + decoded_string symbol.setPath(svg_content) print('embedded svg symbol') else: print('not an svg symbol') except Exception as err: print(err) layers = [layer for layer in QgsProject.instance().mapLayers().values()] for layer in layers: if layer.type() == QgsMapLayer.VectorLayer: try: print(layer.name<http://layer.name>()) render = layer.renderer() render_type = render.type() if render_type == 'singleSymbol': if hasattr(render.symbol(), 'symbolLayers'): for symbol in render.symbol().symbolLayers(): embedSymbol(symbol) else: embedSymbol(render.symbol()) if render_type == 'RuleRenderer': rules = render.rootRule() rules = rules.children() for rule in rules: if hasattr(rule.symbol(), 'symbolLayers'): for symbol in rule.symbol().symbolLayers(): embedSymbol(symbol) else: embedSymbol(rule.symbol()) except Exception as err: print(err) I hope that helps On Tue, 5 Jan 2021 at 12:35, STEINER Andreas <[email protected]<mailto:[email protected]>> wrote: Hello everyone. I tried to load a QGIS Project which was created on windows. In this project I used a svg symbol "symbol/blue-marker.svg". In the .qgis file the path is also "symbol/blue-marker.svg". When I start my qgisserver and request the map there are only this ? questions marks because qgis can't find the blue-marker.svg. [cid:[email protected]] It should look like this: [cid:[email protected]] I tried to copy the symbol folder with the symbols to /usr/lib/cgi-bin/ folder where the qgis_mapserv.fcgi file is located. Didn't work. Then I tried to copy the symbol folder to the location of the .qgis project file. Didn't work. I researched a little bit and found a command to show me what the default svg paths are: python3 from qgis.core import QgsApplication QgsApplication.showSettings() 'Application state:\nQGIS_PREFIX_PATH env var:\t\t/usr/share/qgis/lib/qgis/server\nPrefix:\t\t\nPlugin Path:\t\t\nPackage Data Path:\t/usr/share/qgis/lib/qgis/server/share/qgis\nActive Theme Name:\t\nActive Theme Path:\t/usr/share/qgis/lib/qgis/server/share/qgis/resources/themes//icons/\nDefault Theme Path:\t:/images/themes/default/\nSVG Search Paths:\t\nUser DB Path:\t/usr/share/qgis/lib/qgis/server/share/qgis/resources/qgis.db\nAuth DB Path:\tqgis-auth.db\n' SVG Search Paths:\t\n From there I know that my SVG Search Paths are empty. I can change the variable temporary with: from qgis.core import QgsApplication QgsApplication.setDefaultSvgPaths(['/usr/share/qgis/svg']) but this doesn't help. I also tried to execute this command when creating the docker image but the SVG Search Paths are also empty after that. So in my opinion somewhere this variable can be set but I can't find it, also not in the QGIS Environment variables. Here is my qgis apache2 config: <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName qgis.demo DocumentRoot /var/www/html # Apache logs (different than QGIS Server log) ErrorLog ${APACHE_LOG_DIR}/qgis.demo.error.log CustomLog ${APACHE_LOG_DIR}/qgis.demo.access.log combined # Longer timeout for WPS... default = 40 FcgidIOTimeout 120 FcgidInitialEnv LC_ALL "en_US.UTF-8" FcgidInitialEnv PYTHONIOENCODING UTF-8 FcgidInitialEnv LANG "en_US.UTF-8" # QGIS log (different from apache logs) see https://docs.qgis.org/testing/en/docs/user_manual/working_with_ogc/ogc_server_support.html#qgis-server-logging FcgidInitialEnv QGIS_SERVER_LOG_FILE /var/log/qgis/qgisserver.log FcgidInitialEnv QGIS_SERVER_LOG_LEVEL 0 #FcgidInitialEnv QGIS_PREFIX_PATH /usr/share/qgis/lib/qgis/server FcgidInitialEnv QGIS_PREFIX_PATH /usr FcgidInitialEnv QGIS_PLUGINPATH /opt/qgis-server/plugins FcgidInitialEnv QGIS_DEBUG 0 # default QGIS project SetEnv QGIS_PROJECT_FILE /home/qgis/projects/world.qgs # QGIS_AUTH_DB_DIR_PATH must lead to a directory writeable by the Server's FCGI process user FcgidInitialEnv QGIS_AUTH_DB_DIR_PATH "/home/qgis/qgisserverdb/" FcgidInitialEnv QGIS_AUTH_PASSWORD_FILE "/home/qgis/qgisserverdb/qgis-auth.db" # See https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/supported_data.html#pg-service-file SetEnv PGSERVICEFILE /home/qgis/.pg_service.conf FcgidInitialEnv PGPASSFILE "/home/qgis/.pgpass" # Tell QGIS Server instances to use a specific display number # FcgidInitialEnv DISPLAY ":99" # if qgis-server is installed from packages in debian based distros this is usually /usr/lib/cgi-bin/ # run "locate qgis_mapserv.fcgi" if you don't know where qgis_mapserv.fcgi is ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin/"> AllowOverride None Options +ExecCGI -MultiViews -SymLinksIfOwnerMatch Order allow,deny Allow from all Require all granted </Directory> <IfModule mod_fcgid.c> FcgidMaxRequestLen 26214400 FcgidConnectTimeout 60 </IfModule> </VirtualHost> Thanks for helping 😊 Best regards, Andreas Steiner _______________________________________________ Qgis-user mailing list [email protected]<mailto:[email protected]> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user Email secured by Check Point
_______________________________________________ Qgis-user mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-user Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
