A SVG based mark factory

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

A SVG based mark factory

geowolf
Hi,
working on some OSM styling I've found that nowadays OSM uses mostly
SVG based icons.
The icons are "black", but the CartoCSS style associates them with a color, e.g.:

  [feature = 'amenity_biergarten'][zoom >= 17] {
    marker-file: url('symbols/biergarten.svg');
    marker-fill: @amenity-brown;
    marker-placement: interior;
    marker-clip: false;
  }


So ok, I set up to make an equivalent, by creating a SVG based mark factory, 
work in progress here:


The extraction of shapes turned out to be not too hard, as I could reuse work off the
SVGExternalGraphicFactory. The annoying bit is handling the relative paths, which
is a new concept in WellKnownName.

I looked at a few approaches, including SE 1.1 ExternalMark[1], and eventually settled
down on adding an explicit file reference, like this:

            <Graphic>
              <Mark>
                <WellKnownName>file://hospital.svg</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#FF0000</CssParameter>
                </Fill>
              </Mark>
              <Size>32</Size>
            </Graphic>

which, starting from a black, 14x14 SVG symbol, results in a 32x32 red icon:

Inline image 1

The magic is done, as usual, in SLDParser, and would have to be replicated in the gt-xsd bindings and
inside GeoServer (the data dir handling code).

How does it look? Good approach? Do you have a better (and feasible ;-) ) one? 

Regards,

Andrea Aime


[1] Discarded because we want the entire thing, not a bit inside of a library, and there is no way to write SE 1.1,

so it would be unusable for CSS/Mapbox/YSLD


==
GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information.
==

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
phone: +39 0584 962313
fax: +39 0584 1660272
mob: +39  339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility  for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-Devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-devel
Reply | Threaded
Open this post in threaded view
|

Re: A SVG based mark factory

Ian Turton
Looks good to me, and is a useful upgrade to existing SVG usage too.

Ian

On 30 July 2017 at 21:17, Andrea Aime <[hidden email]> wrote:
Hi,
working on some OSM styling I've found that nowadays OSM uses mostly
SVG based icons.
The icons are "black", but the CartoCSS style associates them with a color, e.g.:

  [feature = 'amenity_biergarten'][zoom >= 17] {
    marker-file: url('symbols/biergarten.svg');
    marker-fill: @amenity-brown;
    marker-placement: interior;
    marker-clip: false;
  }


So ok, I set up to make an equivalent, by creating a SVG based mark factory, 
work in progress here:


The extraction of shapes turned out to be not too hard, as I could reuse work off the
SVGExternalGraphicFactory. The annoying bit is handling the relative paths, which
is a new concept in WellKnownName.

I looked at a few approaches, including SE 1.1 ExternalMark[1], and eventually settled
down on adding an explicit file reference, like this:

            <Graphic>
              <Mark>
                <WellKnownName>file://hospital.svg</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#FF0000</CssParameter>
                </Fill>
              </Mark>
              <Size>32</Size>
            </Graphic>

which, starting from a black, 14x14 SVG symbol, results in a 32x32 red icon:

Inline image 1

The magic is done, as usual, in SLDParser, and would have to be replicated in the gt-xsd bindings and
inside GeoServer (the data dir handling code).

How does it look? Good approach? Do you have a better (and feasible ;-) ) one? 

Regards,

Andrea Aime


[1] Discarded because we want the entire thing, not a bit inside of a library, and there is no way to write SE 1.1,

so it would be unusable for CSS/Mapbox/YSLD


==
GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information.
==

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
phone: <a href="tel:+39%200584%20962313" value="+390584962313" target="_blank">+39 0584 962313
fax: <a href="tel:+39%200584%20166%200272" value="+3905841660272" target="_blank">+39 0584 1660272
mob: <a href="tel:+39%20339%20884%204549" value="+393398844549" target="_blank">+39  339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility  for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-Devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-devel




--
Ian Turton

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-Devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-devel
Reply | Threaded
Open this post in threaded view
|

Re: A SVG based mark factory

jody.garnett
In reply to this post by geowolf
A relative path in a well known name? Is it possible to use external graphic?

--
Jody Garnett

On 30 July 2017 at 13:17, Andrea Aime <[hidden email]> wrote:
Hi,
working on some OSM styling I've found that nowadays OSM uses mostly
SVG based icons.
The icons are "black", but the CartoCSS style associates them with a color, e.g.:

  [feature = 'amenity_biergarten'][zoom >= 17] {
    marker-file: url('symbols/biergarten.svg');
    marker-fill: @amenity-brown;
    marker-placement: interior;
    marker-clip: false;
  }


So ok, I set up to make an equivalent, by creating a SVG based mark factory, 
work in progress here:


The extraction of shapes turned out to be not too hard, as I could reuse work off the
SVGExternalGraphicFactory. The annoying bit is handling the relative paths, which
is a new concept in WellKnownName.

I looked at a few approaches, including SE 1.1 ExternalMark[1], and eventually settled
down on adding an explicit file reference, like this:

            <Graphic>
              <Mark>
                <WellKnownName>file://hospital.svg</WellKnownName>
                <Fill>
                  <CssParameter name="fill">#FF0000</CssParameter>
                </Fill>
              </Mark>
              <Size>32</Size>
            </Graphic>

which, starting from a black, 14x14 SVG symbol, results in a 32x32 red icon:

Inline image 1

The magic is done, as usual, in SLDParser, and would have to be replicated in the gt-xsd bindings and
inside GeoServer (the data dir handling code).

How does it look? Good approach? Do you have a better (and feasible ;-) ) one? 

Regards,

Andrea Aime


[1] Discarded because we want the entire thing, not a bit inside of a library, and there is no way to write SE 1.1,

so it would be unusable for CSS/Mapbox/YSLD


==
GeoServer Professional Services from the experts! Visit http://goo.gl/it488V for more information.
==

Ing. Andrea Aime
@geowolf
Technical Lead

GeoSolutions S.A.S.
Via di Montramito 3/A
55054  Massarosa (LU)
phone: <a href="tel:+39%200584%20962313" value="+390584962313" target="_blank">+39 0584 962313
fax: <a href="tel:+39%200584%20166%200272" value="+3905841660272" target="_blank">+39 0584 1660272
mob: <a href="tel:+39%20339%20884%204549" value="+393398844549" target="_blank">+39  339 8844549

http://www.geo-solutions.it
http://twitter.com/geosolutions_it

AVVERTENZE AI SENSI DEL D.Lgs. 196/2003

Le informazioni contenute in questo messaggio di posta elettronica e/o nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il loro utilizzo è consentito esclusivamente al destinatario del messaggio, per le finalità indicate nel messaggio stesso. Qualora riceviate questo messaggio senza esserne il destinatario, Vi preghiamo cortesemente di darcene notizia via e-mail e di procedere alla distruzione del messaggio stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od utilizzarlo per finalità diverse, costituisce comportamento contrario ai principi dettati dal D.Lgs. 196/2003.

The information in this message and/or attachments, is intended solely for the attention and use of the named addressee(s) and may be confidential or proprietary in nature or covered by the provisions of privacy act (Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection Code).Any use not in accord with its purpose, any disclosure, reproduction, copying, distribution, or either dissemination, either whole or partial, is strictly forbidden except previous formal approval of the named addressee(s). If you are not the intended recipient, please contact immediately the sender by telephone, fax or e-mail and delete the information in this message that has been received in error. The sender does not give any warranty or accept liability as the content, accuracy or completeness of sent messages and accepts no responsibility  for changes made after they were sent or for other risks which arise as a result of e-mail transmission, viruses, etc.



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-Devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-devel



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-Devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/geotools-devel