GeoCat / bridge-style

Cartography library making style format conversions as easy as using Python.
MIT License
44 stars 13 forks source link

only single layer of line marker displayed #13

Open pvgenuchten opened 4 years ago

pvgenuchten commented 4 years ago

On a multilayered line marker, only the first symbol layer is included in sld, i'm not sure if the multilayered line marker case is available in terms of sld spec, or implemented as such in geoserver

geostyler:

                    "kind": "Line",
                    "opacity": 1.0,
                    "perpendicularOffset": 1,
                    "graphicStroke": [
                        {
                            "opacity": 1,
                            "rotate": 0.0,
                            "kind": "Mark",
                            "color": "#ffffff",
                            "wellKnownName": "square",
                            "size": 11.3385826773,
                            "strokeColor": "#000000",
                            "strokeWidth": 1
                        },
                        {
                            "opacity": 1,
                            "rotate": 0.0,
                            "kind": "Mark",
                            "color": "#2395ff",
                            "wellKnownName": "square",
                            "size": 3.7795275591,
                            "strokeColor": "#000000",
                            "strokeWidth": 1
                        }
                    ],
                    "graphicStrokeInterval": 22.6771653546,
                    "graphicStrokeOffset": 1

SLD

<?xml version="1.0" ?>
<StyledLayerDescriptor version="1.0.0" xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd">
  <NamedLayer>
    <Name>double-layered-line-marker</Name>
    <UserStyle>
      <Title>double-layered-line-marker</Title>
      <FeatureTypeStyle>
        <Rule>
          <Name>mr</Name>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>THEMA</ogc:PropertyName>
              <ogc:Literal>mr</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <LineSymbolizer>
            <Stroke>
              <CssParameter name="stroke">#ffffff</CssParameter>
              <CssParameter name="stroke-width">4.762204724466</CssParameter>
              <CssParameter name="stroke-opacity">1.0</CssParameter>
              <CssParameter name="stroke-linejoin">bevel</CssParameter>
              <CssParameter name="stroke-linecap">square</CssParameter>
            </Stroke>
            <PerpendicularOffset>1</PerpendicularOffset>
          </LineSymbolizer>
          <LineSymbolizer>
            <Stroke>
              <GraphicStroke>
                <Graphic>
                  <Mark>
                    <WellKnownName>square</WellKnownName>
                    <Fill>
                      <CssParameter name="fill">#ffffff</CssParameter>
                    </Fill>
                    <Stroke>
                      <CssParameter name="stroke">#000000</CssParameter>
                      <CssParameter name="stroke-width">1</CssParameter>
                    </Stroke>
                  </Mark>
                  <Opacity>1</Opacity>
                  <Size>11.3385826773</Size>
                  <Rotation>0.0</Rotation>
                </Graphic>
              </GraphicStroke>
              <CssParameter name="stroke-dasharray">11.3385826773 22.6771653546</CssParameter>
              <CssParameter name="stroke-dashoffset">1</CssParameter>
            </Stroke>
            <PerpendicularOffset>1</PerpendicularOffset>
          </LineSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>
Screen Shot 2019-09-26 at 11 10 54

double-layered-line-marker.qgz.zip

volaya commented 4 years ago

I think this is a limitation of SLD. I could not find any docs or example about how to add several symbol layers for a line marker. Maybe @jodygarnett can confirm that. For now, the styler library just takes the first one of the symbol layers and ignore the rest

volaya commented 4 years ago

Checking the code, I see that I had already found a solution for that, by adding multiple line symbolizers, one for each symbol layer. However, there was an error in the code that prevented that solution to be applied. Should be working now

pvgenuchten commented 4 years ago

Yes this could work, however currently the positioning of the 2 marks is a bit off, probably because they have different size, which would require different margins?

image polyline-multilayer.qgz.zip

pvgenuchten commented 4 years ago

my impression is that: (sym A size + sym A dash) should be the same as (sym B size + sym B dash) B offset should be (0.5sym A size + sym A dash)+0.5sym b size

volaya commented 4 years ago

right, there is some offset. Not sure how to easily fix that. One of the symbol layers should be taken as the reference, and move the other ones according to its size...