0

I think I've run into a bug in how SLD rules are applied in geoserver. This is on GS 2.12.2 with the css styling extension. In my table I have units that I'd like to render with different icons and different colors based on a few attributes. I'm using red-blue-green cars-trucks-planes. I'd also like to show labels depending on zoom level. I'm testing this with cars only. Currently, when I'm zoomed out only red cars are being rendered, with no labels. The green and blue icons aren't being rendered until I zoom in past 20M, at which point the labels also show up. If I remove the '[@sd < 20M]' from the label rule, everything is shown as expected. I don't entirely understand the ordering in which sld rules are applied, but the fact that only some mark icons are being shown makes this feel like a bug. Let me know if you need any more info.

@mode "Flat";

/* @title Truck Red */
[status = 'A' OR status = 'B'] [vehicle_unit_detail_id IS NOT NULL]  {
  mark: url('http://localhost:8080/geoserver/www/styles/images/...');
}


/* @title Truck Green */
[status = 'C' OR status = 'D' OR status = 'E' OR status = 'F'] [vehicle_unit_detail_id IS NOT NULL]  {
  mark: url('http://localhost:8080/geoserver/www/styles/images/...');
}


/* @title Truck Blue */
[status <> 'A'] [status <> 'B'] [status <> 'C'] [status <> 'D'] [status <> 'E'] [status <> 'F'] [vehicle_unit_detail_id IS NOT NULL]  {
  mark: url('http://localhost:8080/geoserver/www/styles/images/...');
}

/* @title Car Red */
[status = 'A' OR status = 'B'] [vehicle_unit_detail_id IS NULL] [service = 'P'] {
  mark: url('http://localhost:8080/geoserver/www/styles/images/...');
}


/* @title Car Green */
[status = 'C' OR status = 'D' OR status = 'E' OR status = 'F'] [vehicle_unit_detail_id IS NULL] [service = 'P'] {
  mark: url('http://localhost:8080/geoserver/www/styles/images/...');
}


/* @title Car Blue */
[status <> 'A'] [status <> 'B'] [status <> 'C'] [status <> 'D'] [status <> 'E'] [status <> 'F'] [vehicle_unit_detail_id IS NULL] [service = 'P'] {
  mark: url('http://localhost:8080/geoserver/www/styles/images/...');
}

/* @title Plane Red */
[status = 'A' OR status = 'B'] [service = 'N'] {
  mark: url('http://localhost:8080/geoserver/www/styles/images/...');
}


/* @title Plane Green */
[status = 'C' OR status = 'D' OR status = 'E' OR status = 'F'] [service = 'N'] {
  mark: url('http://localhost:8080/geoserver/www/styles/images/...');
}


/* @title Plane Blue */
[status <> 'A'] [status <> 'B'] [status <> 'C'] [status <> 'D'] [status <> 'E'] [status <> 'F'] [service = 'N'] {
  mark: url('http://localhost:8080/geoserver/www/styles/images/...');
}

[@sd < 20M] [@labels(true) = true] {
  label: [vehicle_id], [location_name]; 
  label-anchor: 1.5 0.5, 1.2 2; 
  font-family: "Trebuchet MS Bold";
  font-fill: white;
  font-style: normal;
  font-size: 12; 
  halo-radius: 0.5;
  halo-color: black;
}

EDIT1: I've tried moving the labeling rule into its own FeatureTypeStyle, but I got the same behavior.

EDIT2: I did a small test to see if the issue had something to do with location, but when I created 2 objects in the same location, the red car rendered when zoomed out and the blue one rendered over it when I zoomed in. Doesn't seem like a tiling/location issue.

EDIT3: Here's a pastebin of the generated sld if anyone wants to take a look. https://pastebin.com/cRgDDFGs

6
  • have a look at the generated SLD and see if you can spot the issue in that
    – Ian Turton
    Commented Apr 13, 2018 at 9:13
  • I wasn't able to spot any errors. I did a diff of the working version without '[@sd < 20M]' and the version with it. '<sld:MaxScaleDenominator>2.0E7</sld:MaxScaleDenominator>' was the only new line, right between the filter and text symbolizer for the label rule.
    – Evan
    Commented Apr 13, 2018 at 14:46
  • I tried putting every rule into its own FeatureTypeStyle, because my understanding is that this forces each rule to render independently of the others, at the cost of memory. The behavior was the same - adding the MaxScaleDenominator line breaks the display until I get past 20M
    – Evan
    Commented Apr 13, 2018 at 17:23
  • How are you rendering things? Is tile caching involved at all, which imply you might get stale maps as a result? Try to see the map with the GeoServer layer preview, no tiling. Commented Apr 14, 2018 at 13:26
  • @AndreaAime Tile caching is involved. Right now I'm using almost entirely default settings and testing with the OL preview. I tried emptying the tile cache and previewing as a jpeg, no luck though. The only configuration of any kind that I have done is installing the native linux JAI files. I don't think its relevant, but its running in a linux docker on windows with the data directory mounted from the windows file system.
    – Evan
    Commented Apr 16, 2018 at 14:22

1 Answer 1

0

I found most of an answer. I'll let someone else decide whether or not this is a bug.

/* @title Car Blue */
[status <> 'A'] [status <> 'B'] [status <> 'C'] [status <> 'D'] [status <> 'E'] [status <> 'F'] [vehicle_unit_detail_id IS NULL] [service = 'P'] {
  mark: url('http://localhost:8080/geoserver/www/styles/images/...');
}

In my database, 'status' can be null, which is what this rule is testing for. It seems that null and the cql '<>' operator don't work well together. The missing part of this answer is why does the '[@sd<20M]' filter affect how the blue car rules are evaluating? My guess is that the bad interaction between null and <> produces undefined or some other weird value, which causes the evaluation of the rule to depend solely on '[@sd<20M]'.

I think this should produce some kind of error in the logs, but I wasn't able to find any, even when I swapped to the geotools debugging logging profile.

If anyone has more info I'd love to hear it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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