The class that sets anti-aliasing in GeoServer is: https://svn.codehaus.org/geoserver/branches/1.5.x/geoserver/wms/src/main/java/org/vfny/geoserver/wms/responses/DefaultRasterMapProducer.java

        Map hintsMap = new HashMap();
hintsMap.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        RenderingHints hints = new RenderingHints(hintsMap);
        renderer.setJava2DHints(hints);

So that method above lets you set the Java2d hints.

If transparent GIFS always look bad it could be ok to hack in the code. But better would be to let the client pass in a vendor param to tell geoserver to anti-alias or not. You could code it in the same way we do KMScore for KML. You also could make it an admin option, but I feel like this would be better on a per client basis.

best regards,

Chris

Gary Lucas wrote:
A co-worker of mine had a question regarding anti-aliasing settings and SLD 
files. I took a look through the GeoTools code base and haven’t been able to 
answer him, and I was wondering if anyone here could point me in the right 
direction.

My co-worker is using an Ajax-based web browser application that requests 
transparent GIF files using a WMS request to GeoServer. He uses these GIF’s to 
create a sandwich of overlays, allowing the user to switch between different 
combinations of images depending on what he wants to see (some of the images 
are produced by data systems that are outside scope of the GeoServer 
implementation).
Everything works fine except that the line and text graphics produced by GeoServer are rendered with anti-aliasing. Now typically, when a graphics environment draws a black line on a white background with anti-aliasing, it will attempt to soften that saw-tooth effect that is sometimes visible on angled lines by setting the color of pixels on or adjacent to the line to some intermediate color tone. Thus when my co-worker requests an overlay of geopolitical outlines drawn in a rather dark color and the anti-aliasing in GeoServer assumes a white background, the transparent GIF comes back with dark lines speckled with light gray dots. Of course, he could just change the background, but even as a band-aid fix that doesn’t really work because sometimes he needs to sandwich images on light background and sometimes he uses dark. If we adjust the SLD files for light-colored lines on a dark background, we get a corresponding unsightly effect.

So the question: What’s the best way to suppress the anti-aliasing effects? A 
couple of obvious ideas suggest themselves immediately, but looking through the 
GeoTools code I don’t see any place where they might be implemented (I haven’t 
looked through the GeoServer code because I am still struggling to learn 
GeoTools, and don’t think I could handle another challenge right now). I know 
that an application can suppress aliasing by using the java.awt.RenderingHints 
class, but I’m not sure how to get the proper values passed into GeoTools. I 
thought that there might be a specification in the SLD format to turn off 
aliasing, but I don’t see it in the OpenGIS documents I’ve searched. An 
alternative approach might be to hack the GeoServer code so that when a WMS 
request comes in for a transparent GIF, it just turns off anti-aliasing… except 
that, first, I don’t believe in doing that kind of non-standard stuff if it can 
be avoided and, second, I don’t know wher
e to begin to make the change even if I concluded that was the only way to get 
the job done.

Anyway, I apologize in advance if there’s an easy way of doing this and I’ve 
missed something obvious in the documentation. Thanks for your help.

Gary


P.S. My co-worker has produced some sample images that do an admirable job 
showing the anti-aliasing effect. If anyone is unfamiliar with the effect and 
would like to see what it does, please let me know and I will send copies of 
the images.


---------------------------------------------------------------------------------
Computer Science is the Art of the Possible
Gary W. Lucas, Senior Software Engineer
Sonalysts, Inc
215 Parkway North
Waterford, CT 06320
(860) 326-3682

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

!DSPAM:1003,45f1a2e038087731818748!


--
Chris Holmes
The Open Planning Project
http://topp.openplans.org
begin:vcard
fn:Chris Holmes
n:Holmes;Chris
org:The Open Planning Project
adr:;;349 W. 12th Street, #3;New York;NY;10014;USA
email;internet:[EMAIL PROTECTED]
title:Managing Director, Strategic Development
x-mozilla-html:FALSE
url:http://topp.openplans.org
version:2.1
end:vcard

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to