0

I am using Geoserver and the CSS Style plugin. The following code works fine and shows an 'L' when the feature is 'Left' and the '*' filter catches anything else and shows it as an X.

* {
 mark: symbol('ttf://DejaVu Sans#0x2A02');
 mark-size: 24;
}

[left_right = 'Left'] {
  mark: symbol('ttf://DejaVu Sans#0x004C');
  mark-size: 18;
}

However, when I add a filter for 'Right' then 'R' and 'L' show up but then the catch-all * filter stops working.

* {
 mark: symbol('ttf://DejaVu Sans#0x2A02');
 mark-size: 24;
}

[left_right = 'Left'] {
  mark: symbol('ttf://DejaVu Sans#0x004C');
  mark-size: 18;
}

[left_right = 'Right'] {
  mark: symbol('ttf://DejaVu Sans#0x0052');
  mark-size: 18;
}

I have changed the * rule to the lines below and the symbol still doesn't show up.

[left_right <> 'Right'] [left_right <> 'Left']
[left_right <> 'Right' or left_right <> 'Left']
[left_right = '']

I have also left the * filter alone and added [left_right = ''] as a fourth filter and it doesn't show up either.

I guess I am missing a basic concept of styling rules but I can't figure out what it is. It looks simple to me - I should be able to change my symbol based on the feature attribute. I am not symbolizing unrelated things so I don't see why I would need separate styles.

I have not tried changing the @mode rules since I do not think this should generate an overly complicated SLD style.

What can I change or am I doing wrong?

Full version of the code minus the filter for 'Right':

* {
 mark: symbol('ttf://DejaVu Sans#0x2A02');
 mark-size: 24;
}

[left_right = 'Left'] {
  mark: symbol('ttf://DejaVu Sans#0x004C');
  mark-size: 18;
}

:symbol {
 fill: black;
}


[@scale > 2500] {
  mark-size: 6;
}
  • What are the other values besides "Left" and "Right"? Did you check the generated SLD? – Andrea Aime Aug 14 '16 at 8:27
  • I'll update the question with the full code. I have reviewed the SLD but didn't meticulously go through it hoping for someone more experienced to know the answer offhand. I'll look through it more in-depth. – Barrett Aug 15 '16 at 16:15
  • @AndreaAime Perhaps you weren't asking for the other values of the code but what are other attributes for that field. The other values are: 24"", 33"", 35"", ?,left, and empty lines. These are errors but for now they are in there. – Barrett Aug 15 '16 at 16:21
1

I've checked the generated SLD on GeoServer 2.9.1 but I cannot see an evident misbehavior. The full style cited at the end of your response, that is,

* {
 mark: symbol('ttf://DejaVu Sans#0x2A02');
 mark-size: 24;
}

[left_right = 'Left'] {
  mark: symbol('ttf://DejaVu Sans#0x004C');
  mark-size: 18;
}

:symbol {
 fill: black;
}


[@scale > 2500] {
  mark-size: 6;
}

Generates the rules I would expect, that i:

  • Left and scale < 2500
  • Left and scale > 2500
  • Not Left and scale < 2500
  • Not left and scale > 2500

In SLD:

    <?xml version="1.0" encoding="UTF-8"?><sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" version="1.0.0">
      <sld:NamedLayer>
        <sld:Name>Default Styler</sld:Name>
        <sld:UserStyle>
          <sld:Name>Default Styler</sld:Name>
          <sld:FeatureTypeStyle>
            <sld:Rule>
              <ogc:Filter>
                <ogc:PropertyIsEqualTo>
                  <ogc:PropertyName>left_right</ogc:PropertyName>
                  <ogc:Literal>Left</ogc:Literal>
                </ogc:PropertyIsEqualTo>
              </ogc:Filter>
              <sld:MinScaleDenominator>2500.0</sld:MinScaleDenominator>
              <sld:PointSymbolizer>
                <sld:Graphic>
                  <sld:Mark>
                    <sld:WellKnownName>ttf://DejaVu Sans#0x004C</sld:WellKnownName>
                    <sld:Fill>
                      <sld:CssParameter name="fill">#000000</sld:CssParameter>
                    </sld:Fill>
                  </sld:Mark>
                  <sld:Size>6</sld:Size>
                </sld:Graphic>
              </sld:PointSymbolizer>
            </sld:Rule>
            <sld:Rule>
              <ogc:Filter>
                <ogc:PropertyIsEqualTo>
                  <ogc:PropertyName>left_right</ogc:PropertyName>
                  <ogc:Literal>Left</ogc:Literal>
                </ogc:PropertyIsEqualTo>
              </ogc:Filter>
              <sld:MaxScaleDenominator>2500.0</sld:MaxScaleDenominator>
              <sld:PointSymbolizer>
                <sld:Graphic>
                  <sld:Mark>
                    <sld:WellKnownName>ttf://DejaVu Sans#0x004C</sld:WellKnownName>
                    <sld:Fill>
                      <sld:CssParameter name="fill">#000000</sld:CssParameter>
                    </sld:Fill>
                  </sld:Mark>
                  <sld:Size>18</sld:Size>
                </sld:Graphic>
              </sld:PointSymbolizer>
            </sld:Rule>
            <sld:Rule>
              <ogc:Filter>
                <ogc:PropertyIsNotEqualTo>
                  <ogc:PropertyName>left_right</ogc:PropertyName>
                  <ogc:Literal>Left</ogc:Literal>
                </ogc:PropertyIsNotEqualTo>
              </ogc:Filter>
              <sld:MinScaleDenominator>2500.0</sld:MinScaleDenominator>
              <sld:PointSymbolizer>
                <sld:Graphic>
                  <sld:Mark>
                    <sld:WellKnownName>ttf://DejaVu Sans#0x2A02</sld:WellKnownName>
                    <sld:Fill>
                      <sld:CssParameter name="fill">#000000</sld:CssParameter>
                    </sld:Fill>
                  </sld:Mark>
                  <sld:Size>6</sld:Size>
                </sld:Graphic>
              </sld:PointSymbolizer>
            </sld:Rule>
            <sld:Rule>
              <ogc:Filter>
                <ogc:PropertyIsNotEqualTo>
                  <ogc:PropertyName>left_right</ogc:PropertyName>
                  <ogc:Literal>Left</ogc:Literal>
                </ogc:PropertyIsNotEqualTo>
              </ogc:Filter>
              <sld:MaxScaleDenominator>2500.0</sld:MaxScaleDenominator>
              <sld:PointSymbolizer>
                <sld:Graphic>
                  <sld:Mark>
                    <sld:WellKnownName>ttf://DejaVu Sans#0x2A02</sld:WellKnownName>
                    <sld:Fill>
                      <sld:CssParameter name="fill">#000000</sld:CssParameter>
                    </sld:Fill>
                  </sld:Mark>
                  <sld:Size>24</sld:Size>
                </sld:Graphic>
              </sld:PointSymbolizer>
            </sld:Rule>
            <sld:VendorOption name="ruleEvaluation">first</sld:VendorOption>
          </sld:FeatureTypeStyle>
        </sld:UserStyle>
      </sld:NamedLayer>
    </sld:StyledLayerDescriptor>

A version with also right also generates the 6 rules I would expect:

  • Left and scale < 2500
  • Left and scale > 2500
  • Right and scale > 2500
  • Right and scale < 2500
  • Not Left and Not Right and scale < 2500
  • Not Left and Not right and scale < 2500
  • Hey. I've come up with the same rules which seems to rule out a CSS Plugin issue and now its more a geoserver SLD issue? Nonetheless, it still stand that the * features don't display. Thanks for your time. – Barrett Aug 16 '16 at 14:11
  • That would be a new issue... if you have a sample data set, style, and WMS request that makes it happen, open a ticket and add such information: osgeo-org.atlassian.net/projects/GEOS/summary I don't believe progress can be made without actually looking at the data at this point – Andrea Aime Aug 17 '16 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.