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 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


Back to the top