[OpenLayers-Dev] Rule subclasses and 2.6

Christopher Schmidt crschmidt at metacarta.com
Mon Apr 7 10:16:13 EDT 2008


On Mon, Apr 07, 2008 at 07:40:59AM -0600, Tim Schaub wrote:
> Christopher Schmidt wrote:
> > On Sat, Apr 05, 2008 at 03:30:16PM -0600, Tim Schaub wrote:
> > I don't like encouraging users towards things that are going to change
> > in the next release, but I prefer it over not documenting what I
> > consider an incredibly useful new aspect of working with OpenLayers in
> > 2.6.
> 
> Cool.  Glad we see things the same way.  I'd rather let out a limited 
> set of functionality that we think is more solid.

It sounds to me like we don't see things the same way, in that case? If
so, we should remove Rule subclasses from the OpenLayers code, and not 
include filters, since they're not solid (being only 12 hours old)?

Perhaps you mean 'let out' in a different way than I do. 

> >> * The most useful shortcuts I see are for adding groups of rules to a 
> >> style map.  
> > 
> > Ignoring, for the moment, that I still don't comprehend when to use a
> > Style vs. a StyleMap, I agree so strongly with this that I've actually
> > already started pondering coding equal interval rule creation stuff. 
> 
> Re: StyleMap
> 
> You give a vector layer a style map.  This is functionally a dictionary 
> of named styles.  You can specify a different style for different 
> situations.  A common pattern is to specify a different style when the 
> user selects a feature.  The key in the style map is referred to as the 
> rendering intent.  A typical application might render with one style 
> when sketching a temporary feature, with another style when a feature is 
> persisted, and with another style when a feature is selected.
> 
> The Style class gives you a place to collect groups of rules (color 
> populated cities this way, color ghost towns that way).
> 
> The StyleMap class gives you a way to organize multiple Style instances 
> for use in different situations (switch to this style when user clicks 
> on a feature).

Yeah, I'd gotten that far, except I can't figure out how to make a
StyleMap *do* anything: I thought that the way to do it was something
like StyleMap({default: style, select: select_style}), but then adding
that, when I select a feature, it doesn't change, so I guess I'm just
doing it wrong. 

> Re: equal interval rule creation stuff
> 
> As usual, I'd like to have a big picture talk before adding convenience 
> methods piecemeal.  I think we can create a single method that will be 
> useful for adding a variety of rule groupings.

I've learned the lesson in this release that it's best if I stay out of
working on things that I'm only using for my personal use in OpenLayers.
Popups, Styles and Controls have only been hurt by my intervention in any
part of the process, so I don't intend to add any convenience methods:
I'm just working on writing code that makes it possible to do what I
want more easily. 

> >> OpenLayers.StyleMap.addRuleGroup({
> >>      intents: ["default"], // this would be the default
> >>      type: OpenLayers.Rule.CLASS_BREAKS,
> >>      property: "population",
> >>      values: [0, 10000, 20000, 30000],
> >>      symbolizers: array // length of values.length -1
> > 
> > hm, -1, or plus one? Ah, I guess Infinity can be a number, so -1 is
> > good.
> 
> Confused.  The idea above was that you create a rule for each interval 
> between items in the values array.  That means the number of symbolizers 
> is one less than the length of the values array (one symbolizer for 
> 0>=x>10000, one for 10000>=x>20000, and one for 20000>=x>30000). 
> Anyway, also for later.

Right, I was trying to figure out how this works when you want a rule
for "Anything above this point", which I had assumed was a default; once
I realized that could be explicitly stated, there was no longer a need
for it to be implicit, so my confusion went away. 

> So, in the future, you shouldn't be hand writing OpenLayers rules -
> just like you shouldn't be hand writing SLD.

To me, this statement reads the same as "you shouldn't be hand writing
OpenLayers Layer definitions -- just like you shouldn't be hand writing
WMC." I agree with the latter, but not with the former in all cases.
It seems that there are sets of common rules that are easily constructed
in code -- the example above seems simple enough to me. (Serializing out
to SLD from that is an obvious next step if you care about things other
than OpenLayers.) I don't think that it suffers anymore than doing web
site design without a WYSIWYG editor does: You can still pick out colors
using your color dropper and writing them into code (or in the HTML
case, CSS) without a graphical editor needing to be involved.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Dev mailing list