I think you found a bug; the layer puts a feature listener against the 
datastore; in order to know when to refresh.
I bet by add/remove the georesource you missed the step of hooking up the 
listener?

-- 
Jody Garnett

On Tuesday, 10 May 2011 at 11:08 PM, Joaquín Rodriguez-Guerra Urcelay wrote: 
> You are right, when I create only one layer with a temporary resource, I can 
> modify the features in its georesource, and the layer is refreshed without 
> even invoking layer.refresh() method. 
> However, I dont know why, but If I add 2 temporary layers (invoking the 
> funcion for the first layer twice), then it is like the layers dont notice 
> the changes until I add/remove the modified georesource from them... and then 
> I refresh them. Probably I am missing something, but at leat it is working 
> now :)
> ________________________________________
> De: [email protected] 
> [[email protected]] En nombre de Jody Garnett 
> [[email protected]]
> Enviado el: martes, 10 de mayo de 2011 14:24
> Para: User-friendly Desktop Internet GIS
> Asunto: Re: [udig-devel] WARNING: Bounds crs not defined; assuming bounds 
> from schema
> 
> There is a layer.refresh method? why remove/add georesource again?
> 
> --
> Jody Garnett
> 
> 
> On Tuesday, 10 May 2011 at 9:44 PM, Joaquín Rodriguez-Guerra Urcelay wrote:
> 
> I have seen that removing/adding georesource from layer is not the cause of 
> the warning.
> I think I finally understood that the warning comes from modifying the 
> features in a new temporary resource, and setting this resource in the layer, 
> instead of modifying the features directlr in the layers current georesource.
> Then I can safely remove/add georesource in layer to force the refresh. :)
> Cheers,
> Joaquín
> ________________________________________
> De: 
> [email protected]<mailto:[email protected]>
>  
> [[email protected]<mailto:[email protected]>]
>  En nombre de Joaquín Rodriguez-Guerra Urcelay 
> [[email protected]<mailto:[email protected]>]
> Enviado el: martes, 10 de mayo de 2011 12:52
> Para: User-friendly Desktop Internet GIS
> Asunto: Re: [udig-devel] WARNING: Bounds crs not defined; assuming bounds 
> from schema
> 
> Thanks Jody,
> 
> I noticed that If I add an empty temporaryResource to the map, I dont get any 
> warning
> 
> IGeoResource tempResource = catalog.createTemporaryResource(pathFeatureType);
> Layer layer= layerFactory.createLayer(tempResource);
> layer.setBounds(new ReferencedEnvelope(new Envelope (-180, 180, -90, 90), 
> DefaultGeographicCRS.WGS84));
> layer.setCRS(DefaultGeographicCRS.WGS84);
> System.out.println(layer.getBounds(null, DefaultGeographicCRS.WGS84));
> System.out.println(layer.getGeoResource().getInfo(null).getBounds());
> 
> ReferencedEnvelope[-180.0 : 180.0, -90.0 : 90.0]
> ReferencedEnvelope[0.0 : -1.0, 0.0 : -1.0]
> 
> and If I modify the feature in the temporary resource, then I dont get the 
> warning neither.
> 
> // Add new feature to a new igeoresource
> IGeoResource newGeoresource =D layer.getGeoResource();
> FFeatureStore fs =newGeoresource.resolve(FeatureStore.class, null);
> FFeatureCollection features = FeatureCollections.newCollection();
> features.add(feature);
> fs.addFFeatures(features);
> 
> The problem was ocurring If I created a new temporary resource with new 
> values, and then replace layer's georesource with the new one.
> 
> IGeoResource newGeoresource =D 
> catalog.createTemporaryResource(pathFeatureType);
> System.out.println("CR " 
> +newGeoresource.getInfo(null).getBounds().toString());
> FeatureStore fs =newGeoresource.resolve(FeatureStore.class, null);
> FFeatureCollection features = FeatureCollections.newCollection();
> features.add(feature);
> fs.addFFeatures(features);
> System.out.println(""CD " 
> +newGeoresource.getInfo(null).getBounds().toString());
> // Delete old georesources from layer and add the new one, then refresh
> List<IGeoResource> georesources=Dlayer.getGeoResources();
> while(georesources.size()>0){
> georesources.remove(georesources.size()-1);
> }
> layer.getGeoResources().add(newGeoresource);
> 
> CR ReferencedEnvelope[0.0 : -1.0, 0.0 : -1.0]
> CD ReferencedEnvelope[-6.0 : 14.0, -10.0 : 20.0]
> 
> Although bounds were being updated correctly from [0.0 : -1.0, 0.0 : -1.0] to 
> [-6.0 : 14.0, -10.0 : 20.0] :) , I think the remove/add georesouce thing from 
> layer is not the best way to go. I had to do it this way because I needed to 
> force the renderer to redraw the layer with the modifications, but right now 
> it is working and refreshing just updating the features in the georesouce, so 
> problem solved by now :)
> 
> Cheers
> 
> 
> ________________________________________
> De: 
> [email protected]<mailto:[email protected]>
>  
> [[email protected]<mailto:[email protected]>]
>  En nombre de Jody Garnett 
> [[email protected]<mailto:[email protected]>]
> Enviado el: martes, 10 de mayo de 2011 10:57
> Para: User-friendly Desktop Internet GIS
> Asunto: Re: [udig-devel] WARNING: Bounds crs not defined; assuming bounds 
> from schema
> 
> Interesting; here is what the warning means.
> 
> - we keep a bounding box for the data as part of the IGeoResoruceInfo (so if 
> you hit zoom to layer this is the bounds that it uses)
> - if it cannot find a value there; it looks at the CRS for the layer and 
> makes a "guess" - that is what this warning is about.
> 
> So perhaps our temporary resource code needs the ability to set the 
> IGeoResourceInfo bounds?
> 
> --
> Jody Garnett
> 
> 
> On Tuesday, 10 May 2011 at 4:13 PM, Joaquín Rodriguez-Guerra Urcelay wrote:
> 
> 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 =D 
> catalog.createTemporaryResource(pathFeatureType);
> FeatureStore fs =newGeoresource.resolve(FeatureStore.class, null);
> FFeatureCollection 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,DefaultGeographicCRRS.WGS84 ));
> 
> Thanks,
> 
> Joaquín
> ________________________________________
> De: 
> [email protected]<mailto:[email protected]>
>  
> [[email protected]<mailto:[email protected]>]
>  En nombre de Joaquín Rodriguez-Guerra Urcelay 
> [[email protected]<mailto:[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]<mailto:[email protected]>
>  
> [[email protected]<mailto:[email protected]>]
>  En nombre de Joaquín Rodriguez-Guerra Urcelay 
> [[email protected]<mailto:[email protected]>]
> Enviado el: jueves, 05 de mayo de 2011 18:42
> Para: 
> [email protected]<mailto:[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&ggt; 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));
> 
> TThen, 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 =D 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
> SimpleFFeature feature = featureBuilder.buildFeature("Path");
> 
> // Remove all features from igeoresource and add thee 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.addFFeatures(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
> 
> 
> ______________________
> 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
> 
> ______________________
> 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
> 
> 
> ______________________
> 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
> 
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to