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

Implementing marker halos with two layers #4247

Open
StyXman opened this issue Sep 20, 2021 · 2 comments
Open

Implementing marker halos with two layers #4247

StyXman opened this issue Sep 20, 2021 · 2 comments

Comments

@StyXman
Copy link

StyXman commented Sep 20, 2021

I tried to fake what I asked in #4246, but I hit an issue.

The way I did it is to draw two layers. The lower one uses an SVG, set fill and stroke to white, stroke width to 2. The upper one uses the same SVG only with fill in another color (a shade of red). This should imitate a 1px halo, right?

No. The stroke style is also used in the upper layer. See for yourself:

128

I have a test file:

<?xml version="1.0" encoding="utf-8"?>
<!-- kate: indent-width 2; -->
<!DOCTYPE Map[]>
<Map background-color="#f2efe9" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
  <Parameters>
    <Parameter name="scale">1</Parameter>
    <Parameter name="metatile">4</Parameter>
    <Parameter name="bounds">-180,-85.05112877980659,180,85.05112877980659</Parameter>
    <Parameter name="minzoom">0</Parameter>
    <Parameter name="maxzoom">22</Parameter>
  </Parameters>

  <Style filter-mode="first" name="amenity-points-halo">
    <Rule>
      <Filter><![CDATA[([amenity] = 'fuel')]]></Filter>
      <MarkersSymbolizer clip="false" file="symbols/amenity/fuel.svg" fill="#c00000" stroke="#ffffff" stroke-width="2" width="24" />
    </Rule>
  </Style>
  <Layer cache-features="true" name="amenity-points-halo" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
    <StyleName><![CDATA[amenity-points-halo]]></StyleName>
    <Datasource>
      <Parameter name="type"><![CDATA[csv]]></Parameter>
      <Parameter name="inline"><![CDATA[
        amenity,wkt
        fuel,"POINT (30 10)"
      ]]></Parameter>
    </Datasource>
  </Layer>

  <Style filter-mode="first" name="amenity-points">
    <Rule>
      <Filter><![CDATA[([amenity] = 'fuel')]]></Filter>
      <MarkersSymbolizer clip="false" file="symbols/amenity/fuel.svg" fill="#c00000" width="24" />
    </Rule>
  </Style>
  <Layer cache-features="true" name="amenity-points" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
    <StyleName><![CDATA[amenity-points]]></StyleName>
    <Datasource>
      <Parameter name="type"><![CDATA[csv]]></Parameter>
      <Parameter name="inline"><![CDATA[
        amenity,wkt
        fuel,"POINT (30 10)"
      ]]></Parameter>
    </Datasource>
  </Layer>
</Map>

The SVG is this one.

@StyXman
Copy link
Author

StyXman commented Sep 21, 2021

hmm, I think I made a mistake and I'm actually only seeing the marker from the lower layer...

@StyXman
Copy link
Author

StyXman commented Sep 21, 2021

In fact, yes, that's what I'm seeing. If I comment out the first layer, the right icon shows in the resulting image. I tried to do the same with lines and of course it works, because that's how everybody is implementing road casing. Here's the two other layers I added for that:

  <Style filter-mode="first" name="roads-casing-casing">
    <Rule>
      <Filter><![CDATA[([highway] = 'service')]]></Filter>
      <LineSymbolizer stroke="#999999" stroke-dasharray="22, 11" stroke-linecap="round" stroke-linejoin="round" stroke-width="12" />
    </Rule>
  </Style>
  <Layer name="roads-casing-casing" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
    <StyleName><![CDATA[roads-casing-casing]]></StyleName>
    <Datasource>
      <Parameter name="type"><![CDATA[csv]]></Parameter>
      <Parameter name="inline"><![CDATA[
        highway,wkt
        service,"LINESTRING(-20037508 10, 20037508 10)"
      ]]></Parameter>
    </Datasource>
  </Layer>

  <Style filter-mode="first" name="roads">
    <Rule>
      <Filter><![CDATA[([highway] = 'service')]]></Filter>
      <!-- LineSymbolizer stroke="#ffffff" stroke-linecap="round" stroke-linejoin="round" stroke-width="6.9" /-->
      <LineSymbolizer stroke="#eaeaea" stroke-dasharray="6, 8" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" />
    </Rule>
  </Style>
  <Layer name="roads" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0.0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs +over">
    <StyleName><![CDATA[roads]]></StyleName>
    <Datasource>
      <Parameter name="type"><![CDATA[csv]]></Parameter>
      <Parameter name="inline"><![CDATA[
        highway,wkt
        service,"LINESTRING(-20037508 10, 20037508 10)"
      ]]></Parameter>
    </Datasource>
  </Layer>

Resulting image:

128

I even tried using a PointSymbolizer. DebugSymbolizer works, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant