Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Pattern for updating features based on attribute change


Hi Jody,

See my prior post, but I saw the notes on memory data store and was only using it for mock up purposes. I'm not sure where these tutorials are..somewhere in: http://udig.refractions.net/confluence/display/DEV/1+Getting+Started. But in any case, what you're describing below sounds exactly like my basic use case but I'd like to go a lot further than that.

For agent-based modeling support we do need to provide that ability to move items around on the landscape. But I'd also like to be able to change any kind of map object in real time. For example, you might want to model the spread of an epidemic from region to region in which case you'd want to treat shp file polygons representing those regions as agents and update them dynamically. So really, I can't see any reason beyond performance perhaps to treat the modeled map components any differently than any other components. That would be a much more satisfying approach from the Model point of view but of course you'd also then have the ability for users to treat the VIew just as with any other Geo feature. While it would also be a real advantage -- and inherent in a decent integration -- for users to be able to treat the model objects as regular editable objects that isn't a key need. And in fact, the overhead associated with doing all of the edits through an framework (command stack, etc..) is likely to be too high.

With the approach that I sent in my reply to Andrea I was seeing buffering issues unless I had a wait time of ~500ms for an update, and this was with ~50 polygons. That's actually not a killer assuming that there are some opportunities for improvement  -- It would be lovely to have 60fps :) but actually the user experience can be fine with much less through managing when visualization changes are actually rendered.. But it will all depend on how well it scales to more polygons -- at this point its not clear to me how much that is i/o bound and how much rendering, but it does seem like I need to think a lot about performance issues. For example, I think that there might be update notifications happening at each set attribute, and that's something that would eventually need to be batched. I'm trying to avoid the mistake of premature optimization but at the pilot stage I do want to discover the development path most likely to lead to best performance without losing too much of all of the nice things that uDig supports.

[btw, *total* place holder for future discussions, but have you guys given any thought to supporting 3D vis as primary graphics? THe GEF3D guys are doing really cool things with support for 2 1/2 D graphics and everything I've played around with shows that you almost always get a significant speedup going from AWT/SWT to OpenGL.)

Anyway, the bottom line is that its always possible that for some things super-imposed images / glass pane approach is needed but I'd like to try for a real integration first. And I'll be dealing with the model data internally so on the other hand I don't care as much as most people would about coherency and consistency in the geo model itself.. I'll simply need to make sure that at the moment of any write-back persistence to the geo stores (shape files, etc..) that that is managed well.

probably too much information..

Miles


On Aug 13, 2010, at 7:36 PM, Jody Garnett wrote:

Hi Miles:

Can we back up a moment and ask what it is you are wanting dynamic features for?

There is the rcp tutorial that shows "tracking" of seal gulls or some such; the idea here is similar to "control room" software where you would like to watch in real time where individual animals, boats, trunks are. This approach pretends to have a live feed placing position information in the map blackboard; and then a custom renderer to draw the position information. There is even a special "glass pane" that is used to draw the positions without disturbing the background.

Or are you trying to provide dynamic feedback as people edit features?

I also note that memory datastore is *not* fast; it makes use of a TreeSet internally and is used to mimic the use of a database or filesystem (so data is copied and a duplicate returned). On GeoTools trunk we have a couple faster implementations that used a spatial index (but even then the spatial index needs to be rebuilt as things move - but it makes for faster drawing when zoomed in.).

Jody
 

On 14/08/2010, at 5:47 AM, Miles Parker wrote:

Hi,

I hope this is the appropriate place to ask this question -- not sure if it is a geotools issue or if that even matters. 

I got the map viewer (IViewPart implementation) working well, and I was able to get styles to update dynamically, so I think I more or less have the basic patterns worked out. But I'm having trouble figuring out the recipe for my key use case:

"Change feature attributes dynamically and have those changes reflected on the map."

I have the first part, in that I figured out how that the ShapeFileDataStore was read only. So I created a MemoryDataStore for that. I gather that that is slow, but I couldn't see a better way of making the shape file modifiable. Now, I can get the attributes to change to new values. As I mentioned, I can also get a map to update regularly. But I can't get the values to hook up with the map. 

First, I load in the shape file like so:

            URL resourceId = new URL(

            ICatalog localCatalog = CatalogPlugin.getDefault().getLocalCatalog();
            List<IService> services = CatalogPlugin.getDefault().getServiceFactory().createService(resourceId);
            for (IService service : services) {
                localCatalog.add(service);
                for (IGeoResource resource : service.resources(null)) {

                    FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = resource
                    .resolve(FeatureSource.class, null);




Then, I copy the feature into the memory store (I think..)

                        FeatureCollection<SimpleFeatureType, SimpleFeature> shapeFeatures = featureSource.getFeatures();
                        features = DataUtilities.collection(shapeFeatures);

                        MemoryDataStore mds = new MemoryDataStore(features);
                        mdsStore = mds.getFeatureSource(featureSource.getName());


Now, I can add the original resource into the map..and as I say form that it displays properly, I can modify styles, etc..

                        Layer createLayer = getMap().getLayerFactory().createLayer(resource);
                        getMap().getLayersInternal().add(createLayer);
                        createLayer.getStyleBlackboard().put(SLDContent.ID, style);

Here's where I'm stuck, but perhaps there is a better approach altogether.. I can't actually figure out how to get an IGeoResource for the MapDataStore to add it into the set of layers. I mean, this has to be straightforward but..?

thanks for any hints,

Miles

_______________________________________________
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


Back to the top