Skip to main content

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

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.



Back to the top