Ticket #2146 (closed feature: fixed)

Opened 4 years ago

Last modified 4 years ago

enhance createLiterals to merge context, attributes and data

Reported by: pspencer Owned by: ahocevar
Priority: minor Milestone: 2.9 Release
Component: Style Version: 2.8 RC4
Keywords: Cc:
State: Complete

Description

Attached is a small patch which modifies the createLiterals method of Style to merge the style context, attributes and data to make it possible to map values in the style from multiple places. The incentive for this patch is to allow specifying some style values to come directly from feature.attributes and others to be computed via a function in the style context.

I've included a modification to the Style test that tests getting values from both context and feature attributes in a single createSymbolizer call.

Attachments

createliterals.patch Download (1.9 KB) - added by pspencer 4 years ago.
patch against trunk head to implement merging of context, attributes and data in createLiterals
createliterals2.patch Download (2.1 KB) - added by pspencer 4 years ago.
updated patch adding passing of property being evaluated to createLiteral
createliterals3.patch Download (3.3 KB) - added by ahocevar 4 years ago.
combines createliterals2.patch with the test from createliterals.patch, handle attributes and data in one extend pass

Change History

Changed 4 years ago by pspencer

patch against trunk head to implement merging of context, attributes and data in createLiterals

Changed 4 years ago by pspencer

updated patch adding passing of property being evaluated to createLiteral

Changed 4 years ago by pspencer

I've updated the patch to include passing an optional fourth argument to createLiteral that is the name of the property being evaluated. This is important for me because it allows me to use one function to general several style properties based on the property rather than putting a lot of very similar functions in the context.

I originally proposed to make the third argument of createLiteral an array of arguments that would be blindly passed to String.format. Andreas suggested that using a fourth argument would be more compatible with existing code and so that is the patch I am proposing. Either works for me.

Changed 4 years ago by ahocevar

  • state set to Commit

I uploaded a new patch, which just pulls in the test from Paul's 1st patch. Tests pass in FF3. Paul, this looks good, please commit. And please make sure to document the new feature in  http://trac.openlayers.org/wiki/Styles. I think it will be enough to paste the snippet from http://openlayers.org/pipermail/users/2009-September/013926.html.

Changed 4 years ago by ahocevar

combines createliterals2.patch with the test from createliterals.patch, handle attributes and data in one extend pass

Changed 4 years ago by ahocevar

Another minor change: feature.attributes and feature.data are usually the same, so I changed the original patch to do extend() on these only once.

Changed 4 years ago by pagameba

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

(In [9676]) (Closes #2146) enhance createLiterals to merge context, attributes and pass attribute name through to context functions

Changed 4 years ago by pspencer

forgot to add r=ahocevar

Note: See TracTickets for help on using tickets.