I've been playing around with the various <ogc:Functions> in SLD*. Intrigued
by the "random" function, I tried it out, and was rather surprised to see that
the random number generated appears to remain constant for all rendered
features, but for TextSymbolizers, the random element differs for each feature
labeled. This seems curious to me, and I was wondering if someone could walk
me through how this works.
For example, this SLD styles a point layer with a random fill color**, and then
also creates a text label using the same random function (which understandably
will be a different value from the fill color). In the output, all the points
are always colored the same in a request, but the text labels are all
different. Why the difference?
<Rule>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>circle</WellKnownName>
<Fill>
<CssParameter name="fill">
<ogc:Function name="numberFormat">
<ogc:Literal>'#'000000</ogc:Literal>
<ogc:Mul>
<ogc:Function name="random"></ogc:Function>
<ogc:Literal>1000000</ogc:Literal>
</ogc:Mul>
</ogc:Function>
</CssParameter>
<CssParameter name="fill-opacity">0.7</CssParameter>
</Fill>
<Stroke>
<CssParameter name="stroke">#000000</CssParameter>
</Stroke>
</Mark>
<Size>10</Size>
</Graphic>
</PointSymbolizer>
<TextSymbolizer>
<Label>
<ogc:Function name="numberFormat">
<ogc:Literal>'#'000000</ogc:Literal>
<ogc:Mul>
<ogc:Function name="random"></ogc:Function>
<ogc:Literal>1000000</ogc:Literal>
</ogc:Mul>
</ogc:Function>
</Label>
<Font>
<CssParameter name="font-family">Arial</CssParameter>
<CssParameter name="font-size">12</CssParameter>
<CssParameter name="font-style">normal</CssParameter>
<CssParameter name="font-weight">bold</CssParameter>
</Font>
<LabelPlacement>
<PointPlacement>
<AnchorPoint>
<AnchorPointX>0.5</AnchorPointX>
<AnchorPointY>0.0</AnchorPointY>
</AnchorPoint>
<Displacement>
<DisplacementX>0</DisplacementX>
<DisplacementY>5</DisplacementY>
</Displacement>
</PointPlacement>
</LabelPlacement>
<Fill>
<CssParameter name="fill">#000000</CssParameter>
</Fill>
</TextSymbolizer>
</Rule>
* By the way, if you haven't yet, you all simply _must_ try using the
"categorize" function to collapse a thematic map into a single <Rule>.
** Okay, since there are no hex conversion functions that I know of, the values
only go up to #999999. But this is a test, not a real-world use case!
Thanks,
Mike Pumphrey
OpenGeo - http://opengeo.org
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users