OpenLayers OpenLayers

Ticket #1526 (closed feature: invalid)

Opened 7 months ago

Last modified 7 months ago

applySymbolizer never called if a Style has no Rules

Reported by: sbenthall Assigned to: 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

04/27/08 08:23:22 changed 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?

04/27/08 11:04:43 changed 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.

04/27/08 11:31:27 changed 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.

04/28/08 15:01:11 changed by ahocevar

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

04/28/08 15:08:50 changed 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.

04/28/08 16:39:36 changed by sbenthall

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

04/28/08 16:48:35 changed by ahocevar

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

04/28/08 18:10:56 changed 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).

04/28/08 18:11:45 changed by ahocevar

  • state deleted.