Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] how to refresh a layer

Thank you very much.
I have solved the problem, and I'd like to share it.

The problem is caused by bouds. I use gml datasource to render map. And in gml datasource, there are some code like:

                       Envelope temp = new Envelope();
                        CoordinateReferenceSystem crs=ft.getDefaultGeometry().getCoordinateSystem();
                        FeatureIterator iter = source.getFeatures().features();
                        try{
                        while( iter.hasNext() ) {
                            Feature element = iter.next();
                            if( temp.isNull() )
                                temp.init(element.getBounds());
                            else
                                temp.expandToInclude(element.getBounds());
                        }
                        }finally{
                            iter.close();
                        }
                        bounds=new ReferencedEnvelope(temp,crs);

 So, if you don't set the bounds in GML, udig would calculate it for you. As a result, every layer have diffrent bounds and the layer which contains only one point have  very small bounds. And then, when the point move, it will move out of the bounds quickly.




2009/11/10 Mauricio Pazos <mauricio.pazos@xxxxxxxx>
On Monday 09 November 2009 07:31:57 am redstar wrote:
> I used these cod to refresh the layer:
>
> ILayer layer = LayerUtil.getLayerByName("GPS");
> layer.refresh(ApplicationGIS.getActiveMap().getBounds(null));
>
>
> However, I can see the point moved and moved out of a box bound(quite samll
> bound than map bound), and then disappeared.
We are using the following code to refresh the entire layer.

ILayer target = ...
IMap map = ...
map.getRenderManager().refresh(target, map.getBounds(new
NullProgressMonitor()));

Also, it could be interesting to have a look in MapImpl.getBounds method,
please pay attention in the  following line
bbox = layer.getBounds(null, getViewportModel().getCRS())


cheers


--
Mauricio Pazos
www.axios.es



Back to the top