SVG symbols with modifiable parameters

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

SVG symbols with modifiable parameters

Tamas Szekeres
Hi,

I have a requirement to be able to modify some parameters of the SVG symbols according to the parameters of the corresponding style in the mapfile configuration. This would provide significant help to avoid maintaining large number of SVG definitions with the same shape, but different colors or line widths. Or one could also replace the truetype symbols with the SVG variants if needed.

Would that be reasonable to implement something like this?


I think we could easily modify the SVG definition in msPreloadSVGSymbol, where the symbol definition would be loaded and modified in a local buffer before passing that to the renderer.

Best regards,

Tamas


_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev
Reply | Threaded
Open this post in threaded view
|

Re: SVG symbols with modifiable parameters

Lime, Steve D (MNIT)
Hi Tamas: I think something like this would be super useful. Currently MapServer does not load (directly) or parse the SVG. It's relying on svg-cairo or rsvg for that. So to support parameters one would need to parse and then process the XML looking for parameters. To avoid doing this for every file I'd thinking adding something to a symbolObj to trigger the extra processing might be a possibility. Any chance svg-cairo or rsvg support this (where you'd pass a key/value store along with the filename)?

I was wondering how you'd store the colors, etc... within the mapfile. I don't think that it makes sense to bind it to a styleObj as is. Not enough flexibility for symbols with multiple colors or whatever, plus I'd assume you'd want the flexibility to use SVG files that already define parameter names. So, I'd think we would need to use a hash within the styleObj to hold the configuration parameters something like:

STYLE
  SYMBOL 'some-svg-symbol'
  SIZE 10
  OPTIONS
    'color1' 'red'
    'color2' 'green'
  END
END

--Steve


From: mapserver-dev <[hidden email]> on behalf of Tamas Szekeres <[hidden email]>
Sent: Thursday, September 5, 2019 7:28 AM
To: [hidden email] <[hidden email]>
Subject: [mapserver-dev] SVG symbols with modifiable parameters
 
Hi,

I have a requirement to be able to modify some parameters of the SVG symbols according to the parameters of the corresponding style in the mapfile configuration. This would provide significant help to avoid maintaining large number of SVG definitions with the same shape, but different colors or line widths. Or one could also replace the truetype symbols with the SVG variants if needed.

Would that be reasonable to implement something like this?


I think we could easily modify the SVG definition in msPreloadSVGSymbol, where the symbol definition would be loaded and modified in a local buffer before passing that to the renderer.

Best regards,

Tamas


_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev
Reply | Threaded
Open this post in threaded view
|

Re: SVG symbols with modifiable parameters

Flavio Hendry
Hi Steve and Tamas

wow, what a timing, do you have some spy at our office? CIA? ...

We are just creating some symbol libraries this week and went for SVG
instead of fonts, as font editing programs are a bit quirky ... but
oops, we then realized that we were not able to assign a color ... my
five cents: it would help a lot to be able to assign one color to a
"monocolor" SVG, "monocolor" meaning just black and white and to be able
to assign a color to black. With multicolor SVG, such as for POIs I
don't not really see a sense in altering tons of colors ...

- samples monocolor: https://nodi.mapplus.ch/mono.png
- samples multicolor: https://nodi.mapplus.ch/pois.png



--
Mit freundlichem Gruss / Best regards
Flavio Hendry

----------------------------------------------------------------
TYDAC Inc.  - http://www.tydac.ch
Swiss Maps  - http://www.mapplus.ch
----------------------------------------------------------------
############      Mit freundlichen Gruessen / Kind Regards
############     Flavio Hendry, CEO - mailto:[hidden email]
############         TYDAC AG - http://www.tydac.ch
####    ####        Geographic Information Solutions
####    ####       Optingenstrasse 27 -- CH-3013 Bern
############             Tel +41 (0)31 368 0180
----------------------------------------------------------------
    Location: http://www.mapplus.ch/adr/bern/optingenstrasse/27
----------------------------------------------------------------
_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev
Reply | Threaded
Open this post in threaded view
|

Re: SVG symbols with modifiable parameters

Seth G-2
In reply to this post by Lime, Steve D (MNIT)
From a purely Mapfile syntax point of view it would be nice to add in named styles (as per https://mapserver.org/mapfile/style.html#style - The final intent is to have named styles (Not yet supported) that will be re-usable through the mapfile).

Then for SVG the following syntax could be used, with the name used to match an SVG parameter name:

STYLE
  SYMBOL 'some-svg-symbol'
  NAME 'color1'
  COLOR 255 0 0
END
STYLE
  SYMBOL 'some-svg-symbol'
  NAME 'color2'
  COLOR 0 255 0
END



On Wed, Sep 11, 2019, at 7:01 AM, Lime, Steve D (MNIT) wrote:
Hi Tamas: I think something like this would be super useful. Currently MapServer does not load (directly) or parse the SVG. It's relying on svg-cairo or rsvg for that. So to support parameters one would need to parse and then process the XML looking for parameters. To avoid doing this for every file I'd thinking adding something to a symbolObj to trigger the extra processing might be a possibility. Any chance svg-cairo or rsvg support this (where you'd pass a key/value store along with the filename)?

I was wondering how you'd store the colors, etc... within the mapfile. I don't think that it makes sense to bind it to a styleObj as is. Not enough flexibility for symbols with multiple colors or whatever, plus I'd assume you'd want the flexibility to use SVG files that already define parameter names. So, I'd think we would need to use a hash within the styleObj to hold the configuration parameters something like:

STYLE
  SYMBOL 'some-svg-symbol'
  SIZE 10
  OPTIONS
    'color1' 'red'
    'color2' 'green'
  END
END


--Steve



From: mapserver-dev <[hidden email]> on behalf of Tamas Szekeres <[hidden email]>
Sent: Thursday, September 5, 2019 7:28 AM
To: [hidden email] <[hidden email]>
Subject: [mapserver-dev] SVG symbols with modifiable parameters
 
Hi,

I have a requirement to be able to modify some parameters of the SVG symbols according to the parameters of the corresponding style in the mapfile configuration. This would provide significant help to avoid maintaining large number of SVG definitions with the same shape, but different colors or line widths. Or one could also replace the truetype symbols with the SVG variants if needed.

Would that be reasonable to implement something like this?


I think we could easily modify the SVG definition in msPreloadSVGSymbol, where the symbol definition would be loaded and modified in a local buffer before passing that to the renderer.

Best regards,

Tamas

_______________________________________________
mapserver-dev mailing list
https://lists.osgeo.org/mailman/listinfo/mapserver-dev


_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev
Reply | Threaded
Open this post in threaded view
|

Re: SVG symbols with modifiable parameters

Lime, Steve D (MNIT)
I had thought about this as well. Names would allow you take advantage of attribute binding and expressions. I’d think this would also require a type attribute though since these would be configure-only styles that wouldn’t take part in the normal rendering pipeline. Depends on how much we wanted to support since this would mean 1 param = 1 style. A dictionary might be cleaner.
From: mapserver-dev <[hidden email]> on behalf of Seth G <[hidden email]>
Sent: Wednesday, September 11, 2019 7:05:53 AM
To: [hidden email] <[hidden email]>
Subject: Re: [mapserver-dev] SVG symbols with modifiable parameters
 

This message may be from an external email source.
Do not select links or open attachments unless verified. Report all suspicious emails to Minnesota IT Services Security Operations Center.



From a purely Mapfile syntax point of view it would be nice to add in named styles (as per https://mapserver.org/mapfile/style.html#style - The final intent is to have named styles (Not yet supported) that will be re-usable through the mapfile).

Then for SVG the following syntax could be used, with the name used to match an SVG parameter name:

STYLE
  SYMBOL 'some-svg-symbol'
  NAME 'color1'
  COLOR 255 0 0
END
STYLE
  SYMBOL 'some-svg-symbol'
  NAME 'color2'
  COLOR 0 255 0
END



On Wed, Sep 11, 2019, at 7:01 AM, Lime, Steve D (MNIT) wrote:
Hi Tamas: I think something like this would be super useful. Currently MapServer does not load (directly) or parse the SVG. It's relying on svg-cairo or rsvg for that. So to support parameters one would need to parse and then process the XML looking for parameters. To avoid doing this for every file I'd thinking adding something to a symbolObj to trigger the extra processing might be a possibility. Any chance svg-cairo or rsvg support this (where you'd pass a key/value store along with the filename)?

I was wondering how you'd store the colors, etc... within the mapfile. I don't think that it makes sense to bind it to a styleObj as is. Not enough flexibility for symbols with multiple colors or whatever, plus I'd assume you'd want the flexibility to use SVG files that already define parameter names. So, I'd think we would need to use a hash within the styleObj to hold the configuration parameters something like:

STYLE
  SYMBOL 'some-svg-symbol'
  SIZE 10
  OPTIONS
    'color1' 'red'
    'color2' 'green'
  END
END


--Steve



From: mapserver-dev <[hidden email]> on behalf of Tamas Szekeres <[hidden email]>
Sent: Thursday, September 5, 2019 7:28 AM
To: [hidden email] <[hidden email]>
Subject: [mapserver-dev] SVG symbols with modifiable parameters
 
Hi,

I have a requirement to be able to modify some parameters of the SVG symbols according to the parameters of the corresponding style in the mapfile configuration. This would provide significant help to avoid maintaining large number of SVG definitions with the same shape, but different colors or line widths. Or one could also replace the truetype symbols with the SVG variants if needed.

Would that be reasonable to implement something like this?


I think we could easily modify the SVG definition in msPreloadSVGSymbol, where the symbol definition would be loaded and modified in a local buffer before passing that to the renderer.

Best regards,

Tamas

_______________________________________________
mapserver-dev mailing list
https://lists.osgeo.org/mailman/listinfo/mapserver-dev


_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev
Reply | Threaded
Open this post in threaded view
|

Re: SVG symbols with modifiable parameters

Tamas Szekeres
In reply to this post by Lime, Steve D (MNIT)
Hi Steve,

At the moment I'd address only a simple solution to achieve the desired result, so that the SVG symbols could replace the truetype fonts. So I'd limit the replacement parameters to the properties of symbolStyleObj, but looking a the code, the scale/rotation are already handled, so replacing only color,outlinecolor and width makes any sense. This could probably happened by replacing any occurrences of stroke=".." and fill="..." and stroke-width="..." with the corresponding colors and width from the style definition.

We could probably imagine a support for combined styles using the same SVG definition like you mentioned, but that would be more complicated to implement.

I don't see any chance to manipulate the parsed object from mapserver, because it is not exposed, so we should re-parse the symbol for each color/outlinecolor/width combination, while the parsed result could be stored in the renderer cache for further use.

Best regards,

Tamas


Lime, Steve D (MNIT) <[hidden email]> ezt írta (időpont: 2019. szept. 11., Sze, 7:01):
Hi Tamas: I think something like this would be super useful. Currently MapServer does not load (directly) or parse the SVG. It's relying on svg-cairo or rsvg for that. So to support parameters one would need to parse and then process the XML looking for parameters. To avoid doing this for every file I'd thinking adding something to a symbolObj to trigger the extra processing might be a possibility. Any chance svg-cairo or rsvg support this (where you'd pass a key/value store along with the filename)?

I was wondering how you'd store the colors, etc... within the mapfile. I don't think that it makes sense to bind it to a styleObj as is. Not enough flexibility for symbols with multiple colors or whatever, plus I'd assume you'd want the flexibility to use SVG files that already define parameter names. So, I'd think we would need to use a hash within the styleObj to hold the configuration parameters something like:

STYLE
  SYMBOL 'some-svg-symbol'
  SIZE 10
  OPTIONS
    'color1' 'red'
    'color2' 'green'
  END
END

--Steve


From: mapserver-dev <[hidden email]> on behalf of Tamas Szekeres <[hidden email]>
Sent: Thursday, September 5, 2019 7:28 AM
To: [hidden email] <[hidden email]>
Subject: [mapserver-dev] SVG symbols with modifiable parameters
 
Hi,

I have a requirement to be able to modify some parameters of the SVG symbols according to the parameters of the corresponding style in the mapfile configuration. This would provide significant help to avoid maintaining large number of SVG definitions with the same shape, but different colors or line widths. Or one could also replace the truetype symbols with the SVG variants if needed.

Would that be reasonable to implement something like this?


I think we could easily modify the SVG definition in msPreloadSVGSymbol, where the symbol definition would be loaded and modified in a local buffer before passing that to the renderer.

Best regards,

Tamas


_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev
Reply | Threaded
Open this post in threaded view
|

Re: SVG symbols with modifiable parameters

Tamas Szekeres
In reply to this post by Flavio Hendry
Hi Flavio,

I've already added an RFC which is similar to this problem with the intent to replace the color for a template bitmap symbol:


But that could also be achieved with some kind of color replacement specification in the mapfile and post processing the input bitmap.

However this approach wouldn't handle the 2 colors (stroke and fill color) neither the replacement of the stroke width, which would be a bare minimum to provide an alternative  to the truetype fonts with the corresponding SVG definitions.

Best regards,

Tamas
 


Flavio Hendry <[hidden email]> ezt írta (időpont: 2019. szept. 11., Sze, 8:09):
Hi Steve and Tamas

wow, what a timing, do you have some spy at our office? CIA? ...

We are just creating some symbol libraries this week and went for SVG
instead of fonts, as font editing programs are a bit quirky ... but
oops, we then realized that we were not able to assign a color ... my
five cents: it would help a lot to be able to assign one color to a
"monocolor" SVG, "monocolor" meaning just black and white and to be able
to assign a color to black. With multicolor SVG, such as for POIs I
don't not really see a sense in altering tons of colors ...

- samples monocolor: https://nodi.mapplus.ch/mono.png
- samples multicolor: https://nodi.mapplus.ch/pois.png



--
Mit freundlichem Gruss / Best regards
Flavio Hendry

----------------------------------------------------------------
TYDAC Inc.  - http://www.tydac.ch
Swiss Maps  - http://www.mapplus.ch
----------------------------------------------------------------
############      Mit freundlichen Gruessen / Kind Regards
############     Flavio Hendry, CEO - mailto:[hidden email]
############         TYDAC AG - http://www.tydac.ch
####    ####        Geographic Information Solutions
####    ####       Optingenstrasse 27 -- CH-3013 Bern
############             Tel +41 (0)31 368 0180
----------------------------------------------------------------
    Location: http://www.mapplus.ch/adr/bern/optingenstrasse/27
----------------------------------------------------------------

_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev
Reply | Threaded
Open this post in threaded view
|

Re: SVG symbols with modifiable parameters

Tamas Szekeres
In reply to this post by Seth G-2
Hi Seth,

Naming the styles would make sense in some use cases, but with this approach we would address to use a complex symbol definition within multiple styles. Why don't we separate that complex definition to multiple SVG-s which would then be assigned to multiple styles, which is a common mapserver-ish way to implement complex symbology for the layers.

Best regards,

Tamas


Seth G <[hidden email]> ezt írta (időpont: 2019. szept. 11., Sze, 14:16):
From a purely Mapfile syntax point of view it would be nice to add in named styles (as per https://mapserver.org/mapfile/style.html#style - The final intent is to have named styles (Not yet supported) that will be re-usable through the mapfile).

Then for SVG the following syntax could be used, with the name used to match an SVG parameter name:

STYLE
  SYMBOL 'some-svg-symbol'
  NAME 'color1'
  COLOR 255 0 0
END
STYLE
  SYMBOL 'some-svg-symbol'
  NAME 'color2'
  COLOR 0 255 0
END



On Wed, Sep 11, 2019, at 7:01 AM, Lime, Steve D (MNIT) wrote:
Hi Tamas: I think something like this would be super useful. Currently MapServer does not load (directly) or parse the SVG. It's relying on svg-cairo or rsvg for that. So to support parameters one would need to parse and then process the XML looking for parameters. To avoid doing this for every file I'd thinking adding something to a symbolObj to trigger the extra processing might be a possibility. Any chance svg-cairo or rsvg support this (where you'd pass a key/value store along with the filename)?

I was wondering how you'd store the colors, etc... within the mapfile. I don't think that it makes sense to bind it to a styleObj as is. Not enough flexibility for symbols with multiple colors or whatever, plus I'd assume you'd want the flexibility to use SVG files that already define parameter names. So, I'd think we would need to use a hash within the styleObj to hold the configuration parameters something like:

STYLE
  SYMBOL 'some-svg-symbol'
  SIZE 10
  OPTIONS
    'color1' 'red'
    'color2' 'green'
  END
END


--Steve



From: mapserver-dev <[hidden email]> on behalf of Tamas Szekeres <[hidden email]>
Sent: Thursday, September 5, 2019 7:28 AM
To: [hidden email] <[hidden email]>
Subject: [mapserver-dev] SVG symbols with modifiable parameters
 
Hi,

I have a requirement to be able to modify some parameters of the SVG symbols according to the parameters of the corresponding style in the mapfile configuration. This would provide significant help to avoid maintaining large number of SVG definitions with the same shape, but different colors or line widths. Or one could also replace the truetype symbols with the SVG variants if needed.

Would that be reasonable to implement something like this?


I think we could easily modify the SVG definition in msPreloadSVGSymbol, where the symbol definition would be loaded and modified in a local buffer before passing that to the renderer.

Best regards,

Tamas

_______________________________________________
mapserver-dev mailing list

_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev

_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev
Reply | Threaded
Open this post in threaded view
|

Re: SVG symbols with modifiable parameters

Flavio Hendry
In reply to this post by Flavio Hendry
Hi Steve and Tamas

Me again, one more thought ... I am a big fan of MapServer VECTOR
Symbols, with underestimated potential :-) ... There I can do almost
anything, except "circular segments" (sure, could be done with a zillion
of POINTS).

see https://nodi.mapplus.ch/vector.png
and https://en.wikipedia.org/wiki/Circular_segment

In the sample, all symbols except 2 and 4 four from the left are VECTOR
types, some with STYLE combinations.

2 could be done in such a way:

SYMBOL
NAME 'aw kappe'
TYPE ELLIPSE
FILLED true # or false, can be handled with STYLE
    POINTS
     1 1
    END
    ANGLE 0 # horizontal
    THETA 60 # central angle
    CLOSED true
END

the two parts of 4 could be done in such a way (afetr that STYLEs with
OFFSETs:

SYMBOL
NAME 'aw benzin_left'
TYPE ELLIPSE
FILLED true # or false, can be handled with STYLE
    POINTS
     1 1
    END
    ANGLE 0 # horizontal
    THETA 60 # central angle
    CLOSED false # vertical line
END

SYMBOL
NAME 'aw benzin_right'
TYPE ELLIPSE
FILLED true # or false, can be handled with STYLE
    POINTS
     1 1
    END
    ANGLE 180 # horizontal
    THETA 60 # central angle
    CLOSED false # open, no vertical line
END


--
Mit freundlichem Gruss / Best regards
Flavio Hendry

----------------------------------------------------------------
TYDAC Inc.  - http://www.tydac.ch
Swiss Maps  - http://www.mapplus.ch
----------------------------------------------------------------
############      Mit freundlichen Gruessen / Kind Regards
############     Flavio Hendry, CEO - mailto:[hidden email]
############         TYDAC AG - http://www.tydac.ch
####    ####        Geographic Information Solutions
####    ####       Optingenstrasse 27 -- CH-3013 Bern
############             Tel +41 (0)31 368 0180
----------------------------------------------------------------
    Location: http://www.mapplus.ch/adr/bern/optingenstrasse/27
----------------------------------------------------------------
_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev
Reply | Threaded
Open this post in threaded view
|

Re: SVG symbols with modifiable parameters

Tamas Szekeres
Hi Flavio,

The idea is great. Within the scope of this effort, I think we might probably address this in a more generic way, such as:

1. Add a new symbol type where we can specify the geometries in a WKT or WKB format.
2. Implement support for the curve geometries in the renderers.
3. (Optional: Modify the drivers to provide curve geometries without polygonizing.)

Best regards,

Tamas



Flavio Hendry <[hidden email]> ezt írta (időpont: 2019. szept. 12., Cs, 8:30):
Hi Steve and Tamas

Me again, one more thought ... I am a big fan of MapServer VECTOR
Symbols, with underestimated potential :-) ... There I can do almost
anything, except "circular segments" (sure, could be done with a zillion
of POINTS).

see https://nodi.mapplus.ch/vector.png
and https://en.wikipedia.org/wiki/Circular_segment

In the sample, all symbols except 2 and 4 four from the left are VECTOR
types, some with STYLE combinations.

2 could be done in such a way:

SYMBOL
NAME 'aw kappe'
TYPE ELLIPSE
FILLED true # or false, can be handled with STYLE
    POINTS
     1 1
    END
    ANGLE 0 # horizontal
    THETA 60 # central angle
    CLOSED true
END

the two parts of 4 could be done in such a way (afetr that STYLEs with
OFFSETs:

SYMBOL
NAME 'aw benzin_left'
TYPE ELLIPSE
FILLED true # or false, can be handled with STYLE
    POINTS
     1 1
    END
    ANGLE 0 # horizontal
    THETA 60 # central angle
    CLOSED false # vertical line
END

SYMBOL
NAME 'aw benzin_right'
TYPE ELLIPSE
FILLED true # or false, can be handled with STYLE
    POINTS
     1 1
    END
    ANGLE 180 # horizontal
    THETA 60 # central angle
    CLOSED false # open, no vertical line
END


--
Mit freundlichem Gruss / Best regards
Flavio Hendry

----------------------------------------------------------------
TYDAC Inc.  - http://www.tydac.ch
Swiss Maps  - http://www.mapplus.ch
----------------------------------------------------------------
############      Mit freundlichen Gruessen / Kind Regards
############     Flavio Hendry, CEO - mailto:[hidden email]
############         TYDAC AG - http://www.tydac.ch
####    ####        Geographic Information Solutions
####    ####       Optingenstrasse 27 -- CH-3013 Bern
############             Tel +41 (0)31 368 0180
----------------------------------------------------------------
    Location: http://www.mapplus.ch/adr/bern/optingenstrasse/27
----------------------------------------------------------------

_______________________________________________
mapserver-dev mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/mapserver-dev