I just committed a change to 2.1.x which adds support for the simple
implicit concatenation; it really is the simplest implementation so it
didn't take much time at all to knock out.  I have some build errors on
trunk yet so the improvement won't show up there for a bit yet.  However,
you can check out the CSS docs on the stable manual for info about the label
syntax.  The new feature should be available in the next nightly build of
the community modules for 2.1.x.

On the other hand, having thought about this a bit more, I think it would be
pretty clean to add a function called "expand" or "inject" or something like
that which does templating as you suggest (maybe freemarker, maybe something
lighter-weight like the URL syntax already provided in GeoServer for dynamic
symbolizers.  That could look like:

* { label: expand(The road name is ${st_name} and it is category ${cat}); }

Like the url() function, this could benefit from a few different quoting
schemes which would help to avoid some quoting issues.  So if the implicit
concatenation scheme doesn't work out (and it does prevent some forms of CSS
shorthand in the future) then we can try it as a second alternative.

--
David Winslow
OpenGeo - http://opengeo.org/

On Thu, May 26, 2011 at 12:46 PM, Charles Galpin <[email protected]> wrote:

> Damn, you are fast David :)
>
> Thanks, that works great.
>
> Yes this is rather cumbersome.  I like the idea of implicit concatenation,
> and that as one of the first things I tried but on the first element was
> being used.  And I agree on the whitespace unless you can come up with an
> operator that says "anything inside of this is a literal but I honor
> attributes in [].  Kind of like the difference between "" and '' in perl
> say.
>
> {{The road name is [st_name] and it is category [cat]}}
>
> as opposed to
>
> "The road name is " [st_name] " and it is category " [cat]
>
> Either would be a vast improvement though.
>
> charles
>
> On May 26, 2011, at 12:30 PM, David Winslow wrote:
>
> Yeah, this is one place where SLD is actually less verbose (because it
> magically wraps sequences of expressions in a function call that
> concatenates them as strings.)
>
> This syntax should work (untested though):
>
> label: [strConcat(strConcat(strConcat(strConcat("[", attr1), "] (["),
> attr2), "])")];
>
> Pretty gross, right? If I think about it a bit I could probably make it
> possible to avoid the strConcats; the rule would be that if a list of
> properties is found for a label, it is implicitly concatenated.  I don't
> want to make whitespace significant outside of string literals though, so it
> would come out something like this:
>
> label: "[" [attr1] "] ([" [attr2] "])";
>
> (remember if there are commas that means multiple labels.)
>
> What do you think?
>
> --
> David Winslow
> OpenGeo - http://opengeo.org/
>
> On Thu, May 26, 2011 at 12:20 PM, Charles Galpin <[email protected]> wrote:
>
>> I can't seem to figure out how to use multiple attributes in a label. The
>> tutorial says you can use a CQL expression but I am not sure how to
>> concatenate strings. I'd like to do something like, although this just makes
>> it a literal.
>>
>> label:  "[attr1]  ([attr2])";
>>
>> thanks,
>> charles
>>
>>
>>
>> ------------------------------------------------------------------------------
>> vRanger cuts backup time in half-while increasing security.
>> With the market-leading solution for virtual backup and recovery,
>> you get blazing-fast, flexible, and affordable data protection.
>> Download your free trial now.
>> http://p.sf.net/sfu/quest-d2dcopy1
>> _______________________________________________
>> Geoserver-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>>
>
>
>
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to