Hello,

I was wondering if this warning is familiar to any of you...
I have created a layer containing a TemporaryResource (code below) , and it 
works correctly, but everytime it needs to be rendered, I get the following 
warning:

09-may-2011 12:55:35 org.geotools.map.FeatureLayer getBounds
WARNING: Bounds crs not defined; assuming bounds from schema are correct for 
AbstractDataStore.AbstractFeatureLocking(PathType (4))

Is there any way to set the CRS so I dont get the warning all the time?? I have 
tried setting CRS in the layer, and also in the featureBuilder :S

                                IGeoResource newGeoresource = 
catalog.createTemporaryResource(pathFeatureType);
                                FeatureStore fs 
=newGeoresource.resolve(FeatureStore.class, null);
                                FeatureCollection features = 
FeatureCollections.newCollection();
                                features.add(feature);
                                fs.addFeatures(features);

                                // Delete old georesources from layer and the 
new one
                                List<IGeoResource> 
georesources=pathLayer.getGeoResources();
                                while(georesources.size()>0){
                                        
georesources.remove(georesources.size()-1);
                                }
                                pathLayer.getGeoResources().add(newGeoresource);

                                pathLayer.setBounds(new ReferencedEnvelope(new 
Envelope (-180, 180, -90, 90), DefaultGeographicCRS.WGS84));
                                pathLayer.setCRS(DefaultGeographicCRS.WGS84);
                                
pathLayer.refresh(pathLayer.getBounds(null,DefaultGeographicCRS.WGS84 ));

Thanks,

Joaquín
________________________________________
De: [email protected] 
[[email protected]] En nombre de Joaquín 
Rodriguez-Guerra Urcelay [[email protected]]
Enviado el: viernes, 06 de mayo de 2011 11:04
Para: User-friendly Desktop Internet GIS
Asunto: Re: [udig-devel] Dynamic Features Layer Refresh

I found a way around the problem, instead of using layer.setGeoresource(..) for 
changing the georesource in the layer, I now remove the old georesource and add 
the new one with the following code, and it seems to work correctly :)

layer.getGeoResources().remove(0);
layer.getGeoResources().add(newGeoresource);

cheers,

Joaquín
________________________________________
De: [email protected] 
[[email protected]] En nombre de Joaquín 
Rodriguez-Guerra Urcelay [[email protected]]
Enviado el: jueves, 05 de mayo de 2011 18:42
Para: [email protected]
Asunto: [udig-devel]  Dynamic Features Layer Refresh

Hello,

I am having some troube with a vector layer I created which I would like to 
modify programatically, and I have wiritten some code that works sometimes, and 
some times not. I would appreciate if you could tell me if I am I following the 
right approach for doing this..

I have a table of points that changes over the time, and I want to have a layer 
representing a line following all the points. For this, I created a Temporary 
Resource, and I added it as a layer:

                        // Create path layer
                        List<ILayer> layers = new ArrayList<ILayer>();
                        IGeoResource tempResource = 
catalog.createTemporaryResource(pathFeatureType);
                        Layer layer= layerFactory.createLayer(tempResource);
                        layer.setName(GEORESOURCE_PATH_REAL);
                        layers.add(layer);
                        map.sendCommandASync(new AddLayersCommand(layers));

Then, every time some one inserts a point in the table, I would like to 
recalculate the feature (the line) in the temporary resource and redraw it.


                                Coordinate[] coords= new 
Coordinate[positionsCoords.size()];
                                ....... calculate new line.........
                                LineString line = 
geometryFactory.createLineString(coords);

                                // Create Feature containing the line string
                                // add the attributes in order
                                featureBuilder.add(line);
                                featureBuilder.add(1);
                                featureBuilder.add("Path");
                                // build the feature
                                SimpleFeature feature = 
featureBuilder.buildFeature("Path");

                                // Remove all features from igeoresource and 
add the new one
                                IGeoResource georesource = 
pathLayer.getGeoResource();
                                FeatureStore fs = null;
                                fs = georesource.resolve(FeatureStore.class, 
null);
                                fs.removeFeatures(Filter.INCLUDE);
                                FeatureCollection features = 
FeatureCollections.newCollection();
                                features.add(feature);
                                fs.addFeatures(features);
                                pathLayer.setGeoResource(georesource);
                        }

This piece of code works sometimes, and I can see the new line drawn whenever I 
execute this (in a command or action), but most time the line is not redrawn. I 
have tried using layer.refresh(bounds), but It does not fix it. Is there any 
other way to force the redraw of the layer? I can debug and see that the 
feature was correcly updated in the georesource...

Is this the right approach for doing this?? or maybe there are some other ways 
to do it?

Thanks!

______________________
This message including any attachments may contain confidential 
information, according to our Information Security Management System,
 and intended solely for a specific individual to whom they are addressed.
 Any unauthorised copy, disclosure or distribution of this message
 is strictly forbidden. If you have received this transmission in error,
 please notify the sender immediately and delete it.

______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
 puede contener informacion clasificada por su emisor como confidencial
 en el marco de su Sistema de Gestion de Seguridad de la 
Informacion siendo para uso exclusivo del destinatario, quedando 
prohibida su divulgacion copia o distribucion a terceros sin la 
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje 
 erroneamente, se ruega lo notifique al remitente y proceda a su borrado. 
Gracias por su colaboracion.

______________________

_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to