Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG is not rendered for SVG Marker symbol #50208

Closed
2 tasks done
pathmapper opened this issue Sep 15, 2022 · 7 comments
Closed
2 tasks done

SVG is not rendered for SVG Marker symbol #50208

pathmapper opened this issue Sep 15, 2022 · 7 comments
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Symbology Related to vector layer symbology or renderers Upstream Needs changes in an upstream library (like Qt, Proj, GDAL, ...)

Comments

@pathmapper
Copy link
Contributor

pathmapper commented Sep 15, 2022

What is the bug or the crash?

SVG is not rendered/displayed for SVG Marker symbol.

Steps to reproduce the issue

Use the following SVG for an SVG Marker symbol -> no preview, nothing visible on the map canvas:

abstandsfl_rs.zip

image

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
  #%L
  xplan-workspaces - Modul zur Gruppierung aller Workspaces
  %%
  Copyright (C) 2008 - 2022 lat/lon GmbH, info@lat-lon.de, www.lat-lon.de
  %%
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
  
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU Affero General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  #L%
  -->

<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   version="1.0"
   width="100%"
   height="100%"
   viewBox="-3 -3 100 100"
   id="svg2">
  <defs
     id="defs4">
    <style
       type="text/css"
       id="style6" />
    <symbol
       id="RsAbstandsflaeche"
       style="overflow:visible">
      <path
         d="M 0,0 L 0,-2"
         id="path9"
         style="fill:none;stroke:#000000;stroke-width:0.25" />
      <path
         d="M 0,-2.5 L 0.5,-1.5 L -0.5,-1.5 L 0,-2.5 z"
         id="path11"
         style="fill:#000000;stroke:none" />
    </symbol>
  </defs>
  <use
     transform="matrix(50.583447,0,0,40.21494,47,97.537347)"
     id="use13"
     x="0"
     y="0"
     width="6"
     height="6"
     xlink:href="#RsAbstandsflaeche" />
</svg>

Versions

QGIS version 3.27.0-Master QGIS code revision 9c4d0a2
Qt version 5.15.3
Python version 3.10.4
GDAL/OGR version 3.4.1
PROJ version 8.2.1
EPSG Registry database version v10.041 (2021-12-03)
GEOS version 3.10.2-CAPI-1.16.0
SQLite version 3.37.2
PostgreSQL client version unknown
SpatiaLite version 5.0.1
QWT version 6.1.4
QScintilla2 version 2.11.6
OS version Ubuntu 22.04.1 LTS
       
Active Python plugins
pluginbuilder3 3.2.1
sagaprovider 2.12.99
grassprovider 2.12.99
MetaSearch 0.3.6
processing 2.12.99
db_manager 0.1.20

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

  • I tried with a new QGIS profile

Additional context

No response

@pathmapper pathmapper added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Sep 15, 2022
@agiudiceandrea agiudiceandrea added the Symbology Related to vector layer symbology or renderers label Sep 15, 2022
@troopa81 troopa81 self-assigned this Sep 19, 2022
@troopa81
Copy link
Contributor

There is an issue in Qt, I just opened a ticket : https://bugreports.qt.io/browse/QTBUG-106720

I don't know how to workaround this. If possible, don't use svg:symbol and svg:use together, but I fail to see how Inkscape deals with those item and how to prevent this.

I close the ticket, it needs a fix in Qt.

@troopa81 troopa81 added the Upstream Needs changes in an upstream library (like Qt, Proj, GDAL, ...) label Sep 20, 2022
@pathmapper
Copy link
Contributor Author

Thanks @troopa81 for looking into and reporting it to Qt 👍

I've got hundreds of these from a third party source. If someone knows a way how to automatically convert svg:symbol and svg:use to something else, I'd be happy to learn about. 😄

@troopa81
Copy link
Contributor

@pathmapper Actually, it seems that the symbol tag is not part of the SVG tiny subset supported by Qt, and so QGIS.

So you have to convert from svg to svg tiny. There is this github project which propose to do the conversion https://github.com/manisandro/svg2svgt

Never tested it, hope it helps

@pathmapper
Copy link
Contributor Author

https://github.com/manisandro/svg2svgt

Looks promising, I'll give it a try - thanks for the hint @troopa81.

@pathmapper
Copy link
Contributor Author

svg2svgt just removes the symbol element instead of converting it:

image

Resulting file (not usable):

<?xml version="1.0"?>
<!-- Converted with SVG Converter - Version 0.9.6 (Compiled Thu Aug 31 
10:01:05 2017) - Copyright (C) 2011 Nokia -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-3 -3 100 100" 
id="svg2" xmlns:xlink="http://www.w3.org/1999/xlink" baseProfile="tiny" 
version="1.0" width="100%" height="100%">
   <defs id="defs4"/>
   <use id="use13" 
transform="matrix(50.583447,0,0,40.21494,47,97.537347)" y="0" 
xlink:href="#RsAbstandsflaeche" width="6" x="0" height="6"/>
</svg>

But the <use> element is supported by SVG Tiny, and replacing <symbol> with <g> seems to work at least for the sample SVG provided above:

<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   version="1.0"
   width="100%"
   height="100%"
   viewBox="-3 -3 100 100"
   id="svg2">
  <defs
     id="defs4">
    <style
       type="text/css"
       id="style6" />
    <g
       id="RsAbstandsflaeche"
       style="overflow:visible">
      <path
         d="M 0,0 L 0,-2"
         id="path9"
         style="fill:none;stroke:#000000;stroke-width:0.25" />
      <path
         d="M 0,-2.5 L 0.5,-1.5 L -0.5,-1.5 L 0,-2.5 z"
         id="path11"
         style="fill:#000000;stroke:none" />
    </g>
  </defs>
  <use
     transform="matrix(50.583447,0,0,40.21494,47,97.537347)"
     id="use13"
     x="0"
     y="0"
     width="6"
     height="6"
     xlink:href="#RsAbstandsflaeche" />
</svg>

@troopa81
Copy link
Contributor

troopa81 commented Sep 28, 2022

@pathmapper good to know, I was wondering what was the difference between symbol and g

@pathmapper
Copy link
Contributor Author

@kraftto found a better way using the Inkscape CLI for removing the internal links and <symbol>-elements.

From kreis-viersen/xplan-reader#2 (comment):

inkscape --actions="select-all:all;object-unlink-clones;select-all:groups;object-to-path;export-plain-svg;vacuum-defs" --export-filename=<out-file> <in-file>

results in

<svg
   version="1.0"
   width="100%"
   height="100%"
   viewBox="-3 -3 100 100"
   id="svg2"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:svg="http://www.w3.org/2000/svg">
  <defs
     id="defs4">
    <style
       type="text/css"
       id="style6" />
  </defs>
  <g
     id="use13"
     transform="matrix(50.583447,0,0,40.21494,47,97.537347)">
    <path
       d="M 0,0 V -2"
       id="path12"
       style="fill:none;stroke:#000000;stroke-width:0.25" />
    <path
       d="m 0,-2.5 0.5,1 h -1 z"
       id="path14"
       style="fill:#000000;stroke:none" />
  </g>
</svg>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Symbology Related to vector layer symbology or renderers Upstream Needs changes in an upstream library (like Qt, Proj, GDAL, ...)
Projects
None yet
Development

No branches or pull requests

3 participants