[geotk] Next step for WMS

johann sorel johann.sorel at geomatys.fr
Thu Aug 27 07:30:45 EDT 2009


Hi,
read bellow

Sam B a écrit :
> Well, what I do to set the sizes of my objects is ("this" represents a 
> JFrame object) :
>
>         this.setSize(400, 400);
>         mapWidget = new JMap2D();
>         mapWidget.setSize(400, 400);
>
>         context = MapBuilder.createContext(DefaultGeographicCRS.WGS84);
>
>         mapWidget.getContainer().setContext(context);
>         
> mapWidget.getCanvas().setRenderingHint(GO2Hints.KEY_MULTI_THREAD, 
> GO2Hints.MULTI_THREAD_OFF);
>
>         
> mapWidget.getCanvas().setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
>         mapWidget.getCanvas().getController().setAutoRepaint(true);
>
>         add(mapWidget) ;      
>         Rectangle rect = new Rectangle(0, 0, 400, 400);
>         GeneralEnvelope env = new GeneralEnvelope(rect.getBounds2D());
>         context.setAreaOfInterest(env);
>
mapWidget.setSize(400, 400);
this is useless, let the swing layout manage the size of your component 
automaticly.

mapWidget.getCanvas().setRenderingHint(GO2Hints.KEY_MULTI_THREAD, 
GO2Hints.MULTI_THREAD_OFF);
you can remove this one. muthithreading is still in development and is 
by default in OFF mode.

Rectangle rect = new Rectangle(0, 0, 400, 400);
GeneralEnvelope env = new GeneralEnvelope(rect.getBounds2D());
context.setAreaOfInterest(env);

The AreaOfInterest is something inherited from GeoTools, but this so 
technicaly limited that the go2 renderer
doesnt use it. Use it as an information attribut of the mapcontext.
If you want to set the area you want to see on the canvas, use the 
different setter method you can find on the
canvas controller.
A major difference with geotools, is that the same mapcontext can be 
used with several renderer at the same time, for exemple
you can display 3 differents maps of different areas of the same 
mapcontext (this work both for 2D and 3D engines)

for information, the rendering architecture is divided in 3 interfaces :
- the canvas : the are where the painting will be, it can be a 
BufferedImage, a swing component,
a graphics2d area in a jasper report template or anything that works 
with Java2D .
- the controller : you find here all methods to navigate and controller 
the canvas geographic rendering area
unlike the streaming renderer, the go2 engine is using affine transform 
as it's base, so it can handle much more
than simple x,y translation and scale. it handle shear, rotation and 
unproportional x/y axis.
- the container : this is where every graphic object are stored for 
rendering. the basic use is to have
a container that handle MapContext objects (that's what you have by 
default when you create a J2DCanvas), but it's not a absolute necessity, 
you can make your own implementation of container to manage any data 
structure or caching system you want.

> Is it the right way of doing it ? I noticed in a previous email by 
> theuns that he does a
>     private MapContext contextSA = ContextBuilder.buildSouthAfricaContext();
>
> but I was not able to find the ContextBuilder. Is it an old version ?
>   
The contextBuilder is just a utility class I was using in the past to 
build predefined MapContexts for debugging purposes.
Theuns have something similar because he's on the projet since several 
months (is it one year already you're on it theuns ? )
when he arrived, thoses debugging classes were still on the trunk, they 
dont exist anymore exept on my separate debugging
application.

> By the way, looking at puzzle gis, I noticed that the URL for the WMS server contains the "&STYLES=null" argument, which makes the server to send a blank image.
> Is it a way to get rid of this ?
>   
I'll have to check it when I come back from vacation,
I don't have a powerfull enough computer here to build everything smoothly.
It would be a real pain to do it here.

johann


More information about the Geotoolkit mailing list