Ticket #1526 (closed feature: invalid)

Opened 5 years ago

Last modified 5 years ago

applySymbolizer never called if a Style has no Rules

Reported by: sbenthall Owned by: ahocevar
Priority: minor Milestone:
Component: Style Version: 2.6
Keywords: Cc:
State:

Description

If a Style had no Rules, then applySymbolizer is never called. This is a problem because:

(1) applySymbolizer is the only place where, if a symbolizer is a hash of other symbolizers indexed by geometry type, the appropriate latter symbolizer is chosen and applied,

but

(2) there are lots of ways to make a Style without a rule. In fact, the StyleMap code itself does this in its constructor given certain kinds of input.

Tschaub tells me that the expectation is that a Style will always have at least one Rule, but if this is the case, then there's something wrong with StyleMap. In any case, there seems to be some inconsistency in the expectations of various parts of the styling code.

Change History

Changed 5 years ago by ahocevar

  • state set to Awaiting User Feedback

Seb: I'm not sure I understand exactly what is wrong here. Can you please provide some example code to see when the problem you are describing occurs?

Changed 5 years ago by tschaub

I think it goes something like this:

var style = new OpenLayers.Style(
    {externalGraphic: "${getExternalGraphic}"},
    {context: {
        getExternalGraphic: function(feature) {
            return "foo.png";
        }
    }}
);

You can see that createSymbolizer only calls applySymbolizer if a style has rules.

Changed 5 years ago by ahocevar

  • state changed from Awaiting User Feedback to Needs More Work

Thanks Tim, now the problem is obvious to me. I am working on it, patch will follow.

Changed 5 years ago by ahocevar

(In [7023]) added an additional test to show that the example given by tschaub for #1526 works without modifications (references #1526)

Changed 5 years ago by ahocevar

  • state changed from Needs More Work to Needs Discussion

The symbolizer given in Tim's example above will also be evaluated without applySymbolizer.

So the question is: does applySymbolizer need to be called if there are no rules? applySymbolizer is intended to evaluate rules, nothing else. And the only place where a hash of symbolizers keyed by geometry type is allowed, is inside a rule. This should be clear from the ND comments.

I still don't see anything wrong the way it is now, but I'm open to discuss (or even implement) ideas Seb or others might have.

Changed 5 years ago by sbenthall

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

Changed 5 years ago by ahocevar

(In [7024]) More detailled comment for Rule.symbolizer. Non-functional change (references #1526)

Changed 5 years ago by ahocevar

See #1531 for information on how to create styles that are different for point, line and polygon geometries (which is e.g. useful for OSM, where one layer can contain point, line and polygon features at the same time).

Changed 5 years ago by ahocevar

  • state Needs Discussion deleted
Note: See TracTickets for help on using tickets.