Ticket #1876 (closed bug: fixed)

Opened 5 years ago

Last modified 4 years ago

Stroke defaults missing when reading SLD format

Reported by: ahocevar Owned by: tschaub
Priority: minor Milestone: 2.8 Release
Component: Format.SLD Version: 2.7
Keywords: Cc:
State: Complete

Description

Currently, a geometry gets rendered with a stroke when the symbolizer's strokeWidth has a value. This is not compliant with SLD. Instead, a stroke is to be drawn when strokeWidth or strokeColor has a value.

Attachments

1876-r8509-A0.patch Download (487 bytes) - added by ahocevar 5 years ago.
1876-r8509-B0.patch Download (0.9 KB) - added by ahocevar 5 years ago.
Alternative solution - handles the problem in Format.SLD
1876.patch Download (4.4 KB) - added by ahocevar 4 years ago.
introducing defaultsPerSymbolizer
1876.2.patch Download (21.3 KB) - added by ahocevar 4 years ago.
with new stroke, fill and graphic symbolizer properties (boolean)
1876.3.patch Download (21.0 KB) - added by tschaub 4 years ago.
stroke, fill, and graphic

Change History

  Changed 5 years ago by ahocevar

(In [8509]) fixed check to determine if stroke should be rendered. (references #1876)

Changed 5 years ago by ahocevar

  Changed 5 years ago by ahocevar

  • state set to Review

  Changed 5 years ago by ahocevar

  • status changed from new to closed
  • resolution set to invalid

Invalid - since this is related to SLD, it should be handled in the SLD Format reader.

  Changed 5 years ago by ahocevar

(In [8510]) reverted previous change (references #1876)

Changed 5 years ago by ahocevar

Alternative solution - handles the problem in Format.SLD

  Changed 5 years ago by ahocevar

  • status changed from closed to reopened
  • resolution invalid deleted
  • state changed from Review to Needs More Work
  • component changed from Renderer.Elements to Format.SLD

added another patch to handle this in Format.SLD. This patch might be incomplete.

  Changed 5 years ago by ahocevar

  • summary changed from Wrong check to determine if stroke should be rendered to Stroke defaults missing when reading SLD format

  Changed 4 years ago by ahocevar

  • status changed from reopened to new

  Changed 4 years ago by ahocevar

  • status changed from new to assigned

  Changed 4 years ago by ahocevar

  • owner changed from ahocevar to tschaub
  • status changed from assigned to new
  • state changed from Needs More Work to Review

The original reason for creating this patch was that when using OpenLayers.Renderer outside a map, and for just rendering a feature with a rule instead of a style (which makes sense for rendering a client-side legend of a layer), rules with e.g. no strokeColor are not rendered. When rendering features on a map, after using style.createSymbolizer(), a defaultStyle (which is also assigned to the Style objects that Format.SLD creates), will alwas be extended with styles found in rules. Now if we render a rule standalone, the symbolizers for the rule only have the properties that were found in the SLD.

To fix this, and to not interfer with the current way OpenLayers creates the symbolizer for a feature (extending the default symbolizer, and then extending the resulting symbolizer with every rule), I introduced a config option defaultsPerSymbolizer. When this is set to true, each symbolizer will get the relevant properties (i.e. stroke properties for a Stroke, fill properties for a Fill, and graphic properties for a Graphic).

The new patch comes with tests, tests pass in FF3. Thanks for any review.

Changed 4 years ago by ahocevar

introducing defaultsPerSymbolizer

follow-up: ↓ 12   Changed 4 years ago by tschaub

Can't the render be educated so that {strokeColor: "red"} renders a 1px wide red stroke? I'm sure I'm missing something, but I would think this could be a fix in the renderers instead of requiring setting a non-default property value. I'll ask for more detail tomorrow.

  Changed 4 years ago by tschaub

I imagine folks who create OL rules without the SLD parser would want a similar solution, right?

in reply to: ↑ 10 ; follow-up: ↓ 13   Changed 4 years ago by ahocevar

Replying to tschaub:

Can't the render be educated so that {strokeColor: "red"} renders a 1px wide red stroke? I'm sure I'm missing something, but I would think this could be a fix in the renderers instead of requiring setting a non-default property value. I'll ask for more detail tomorrow.

The problem is that the renderer cannot know if you want a fill or not. So if you don't specify any fill* symbolizer property, is that because you want the default ones or because you don't want a fill to be rendered?

My proposed patch just implements the way SLD would create symbolizers (i.e. stroke, fill and graphic are all separate).

in reply to: ↑ 12   Changed 4 years ago by tschaub

Replying to ahocevar:

Replying to tschaub:

Can't the render be educated so that {strokeColor: "red"} renders a 1px wide red stroke? I'm sure I'm missing something, but I would think this could be a fix in the renderers instead of requiring setting a non-default property value. I'll ask for more detail tomorrow.

The problem is that the renderer cannot know if you want a fill or not. So if you don't specify any fill* symbolizer property, is that because you want the default ones or because you don't want a fill to be rendered? My proposed patch just implements the way SLD would create symbolizers (i.e. stroke, fill and graphic are all separate).

Currently, we fill polygons orange by default. If you create a style map with styles with no fill properties, you get a black fill. If you don't want a fill, you set fillOpacity to 0. Right?

  Changed 4 years ago by tschaub

Andreas, how about a non-api property? We've got a number of style related things that could use work and the less we have to worry about backwards compatibility the better (in my mind).

  Changed 4 years ago by tschaub

We talked about having stroke and fill properties (at least) on symbolizers as a way to explicitly state if a stroke or fill should be rendered. If set to a boolean, these should be respected (and should have precedence over more specific properties).

  Changed 4 years ago by tschaub

  • owner changed from tschaub to ahocevar

  Changed 4 years ago by ahocevar

My latest patch introduces the mentioned fill, stroke and graphic symbolizer properties. These come in handy if one wants to

  • draw labels without a feature (set to false)
  • extend incomplete symbolizers with defaults for stroke, fill or graphic (set to true, in addition to Style.defaultsPerSymbolizer set to true)

Format.SLD sets these properties to true, so finally setting <Stroke/> will draw a default stroke without changing the SLD when writing it back.

Added tests and example. Tests continue to pass in FF3, example tested in FF3 (SVG and Canvas), IE6, IE7 and Safari.

  Changed 4 years ago by ahocevar

  • owner changed from ahocevar to tschaub

Changed 4 years ago by ahocevar

with new stroke, fill and graphic symbolizer properties (boolean)

  Changed 4 years ago by ahocevar

(In [9267]) introduced new stroke, fill and graphic symbolizer properties (see #1876)

Changed 4 years ago by tschaub

stroke, fill, and graphic

follow-up: ↓ 21   Changed 4 years ago by tschaub

  • state changed from Review to Commit

Thanks for all the work on this Andreas.

Since the example is the same with or without the non-api defaultsPerSymbolizer property being set, I'd prefer not to see it used there. Also, I like the idea of example pages having a title and at least some of the elements that are used by the example parser. If you don't mind, please commit the version with the updated example.

Also, it's not immediately clear to me what we'd break if we set that defaultsPerSymbolizer thing to true (by default). I can see that it would make a difference, just not sure exactly where (in whose applications).

Anyway, I look forward to revisiting symbolizers after 2.8.

Thanks again for making this work.

in reply to: ↑ 20   Changed 4 years ago by ahocevar

Replying to tschaub:

Also, it's not immediately clear to me what we'd break if we set that defaultsPerSymbolizer thing to true (by default). I can see that it would make a difference, just not sure exactly where (in whose applications).

I am also not exactly sure where it would break things, but it probably has an impact on performance because of the many applyDefaults calls.

  Changed 4 years ago by ahocevar

  • status changed from new to closed
  • state changed from Commit to Complete
  • resolution set to fixed

(In [9278]) * added stroke, fill and graphic symbolizer properties (all boolean) to control whether or not to render a stroke, fill and graphic.

  • added a defaultsPerSymbolizer property to OpenLayers.Style to allow

for extending incomplete symbolizers with defaults for stroke, fill or graphic. This also makes Format.SLD read/write round trips possible without modifying empty or incomplete <Stroke/>, <Fill/> and <Graphic/> constructs. r=tschaub (closes #1876)

Note: See TracTickets for help on using tickets.