Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Problem with FeatureCollection, FeatureTableControl and CollectionListener

Hi Ingmar,

So I have a few points.

1. I think in the case of the Geometry column always being GEOMETRY isn't actually caused by createTemporaryResource(). I just checked. You can see the feature type of a layer by right click on a layer and viewing its properties. 2. I am dragging this out of the dark corners of my mind but if I remember correctly it is actually the FeatureTableControl that does that. For some reason the implementor decided to label the Geometry column GEOMETRY always. And I think it just displays the type of geometry. 3. A very minor point: You are getting LATLONG by using CRS.decode("EPSG"4326") this is not the most efficient way of doing it, at least for this version of uDig. I'd suggest DefaultGeographicCRS.WGS84.

Now for your question about events. There are a few things you have to know.

1. Most events that are fired from feature operations will occur in a background thread so they cannot update the UI directly. Rather you have to run the update in the Display thread.

The display thread can usually be obtained by: PlatformUI.getWorkbench().getDisplay();

Now that you have the display you can run a runnable in the display thread using the method syncExec(runnable) or asyncExec(runnable).

2. To get a commit event from the FeatureStore is VERY hard right now, although we are fixing on uDig/Geotools trunk. So for the commit event I would suggest listening to the EditManager. For the individual edit events I would listen to the FeatureSource as you are doing.

Hope this helps,

Jesse

Le 14-Feb-08 à 4:26 PM, Ingmar Eveslage a écrit :


Hello,

i try to do the following:

//create FeatureType
	CoordinateReferenceSystem crs = CRS.decode("EPSG:4326");
	AttributeType point =
AttributeTypeFactory.newAttributeType("Location",Point.class,true,
null,null,crs );
	AttributeType name = AttributeTypeFactory.newAttributeType("Name",
String.class, false, null, "Station", null);
FeatureType stationFeatureType = FeatureTypeBuilder.newFeatureType(new
AttributeType[] { point, name }, "StationFeatureType");

//create IGeoResource
	IGeoResource stationGeoResource =
CatalogPlugin .getDefault ().getLocalCatalog().createTemporaryResource(stationFeatureType);

//create list of IGeoResource
	List <IGeoResource> geoResourceList = new LinkedList<IGeoResource>();
	geoResourceList.add(stationGeoResource);

//create new map
	ApplicationGIS.createAndOpenMap(geoResourceList, null, true);

//get the new layer
	ILayer stationLayer = null;
	List <ILayer> layerList = network.getEditorMap().getMapLayers();
	for (ILayer layer: layerList) {
		if (layer.getName().compareTo("StationFeatureType") == 0)
			stationLayer = layer;
	}

//get FeatureSource
	FeatureSource stationFeatureSource =
stationLayer.getResource(FeatureSource.class, null);

//get FeatureCollection
	FeatureCollection features = stationFeatureSource.getFeatures();

//AFTER all this i create i view wich displays a FeatureTableControl
FeatureTableControl ftc = new FeatureTableControl(parent, features);

All seams fine, but i notices a few problems:

1) the automatic created column header for the AttributeType point is
"GEOMETRY". but i defined it as "Location". The first thing is a
nullPointerException if the FeatureTableControl wants to display a feature. When i change the name of my attributetype to "GEOMETRY" all is fine. But i
think this is a bug.

2) if i add features to the layer, no updates in the table will be
displayed. and i do not realy know which listener i should take. i tried the
following:
every implementation of the changed method makes a tfc.update.

map.getEditManager().addListener(view_i_created);
--> all updates are seen, but if i make i commit of the station layer i get
a "invalid thread access exception"
stationFeatureSource.addFeatureListener(view_i_created);
--> all updates are listed in the table, but the commit of the station layer makes no update. so all the FID are still "new*" and not the real one
features.addListener(view_i_created);
	--> nothing happens. no CollectionEvent fired

i looked in the FeatureTableControl implementation and i think this
implementation uses the CollectionListener interface too. but when no
CollectionEvents are fired, no updates are displayed.

i hope someone can help me with my 2 problem. perhaps this are bugs or do i
missunderstand the api?

thanks forward

Ingmar


--
View this message in context: http://www.nabble.com/Problem-with-FeatureCollection%2C-FeatureTableControl-and-CollectionListener-tp15492607p15492607.html
Sent from the udig-devel mailing list archive at Nabble.com.

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



Back to the top