On Thu, Oct 28, 2010 at 10:52 PM, Mike Pumphrey <m...@opengeo.org> wrote:
> 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?

Because GeoServer SLD subsystem thinks the call to the function will
always return the same value since
it uses no attributes as parameters. Almost all functions do that, if
the input are static they just always
return the same value.
But random does not, and we have no way to tell the rendering
subsystem it is different.... I'm sorry I don't
have a workaround for this one, an API change would be needed, or we'd
have to make the renderer
consider function usage as something that prevents caching... well
given the average function usage
it would make sense in fact.

On labels it works because there is no "cache and reuse" optimization
for those symbolizers, as they
are almost never using the same label over and over.

Just for the sake of discussion, you probably don't want a truly
random number, since that would make
every paint of the map different, but probably some pseudorandom
generator that happens to generate
the same value for the same feature, again, possibly based on some
attribute of the feature (if stable,
its id would be a good candidate).

Cheers
Andrea

-----------------------------------------------------
Ing. Andrea Aime
Senior Software Engineer

GeoSolutions S.A.S.
Via Poggio alle Viti 1187
55054  Massarosa (LU)
Italy

phone: +39 0584962313
fax:     +39 0584962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

-----------------------------------------------------

------------------------------------------------------------------------------
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
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to