Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[udig-devel] Feature Selection using example

Hello all,

Having a problem using the example (taken from this glorious list) returning
a collection of features 
for the current layer.  Basically it always returns a collection of size 0.

Here is the method I'm using :

public FeatureCollection getFeaturesSelectedOnLayer ()
	{
		net.refractions.udig.project.internal.Map currentMap =
ApplicationGISInternal.getActiveMap();
		Layer layer = currentMap.getEditManagerInternal().getSelectedLayer();
		Query query = new DefaultQuery(layer.getSchema().getTypeName(),
layer.getFilter(),new String[]{"the_geom"});
		FeatureIterator featureIterator = null;
		FeatureCollection features = null;
		try{
	        IProgressMonitor monitor = new NullProgressMonitor();
	        FeatureSource featureSource =
layer.getResource(FeatureSource.class, monitor);
	        features = featureSource.getFeatures(query);
	        featureIterator = features.features();
	        aLogger.info("features selected are : " + features.size() + "type
name is " + layer.getSchema().getTypeName() + "..is selectable? " +
layer.isSelectable());
	        while(featureIterator.hasNext() )
		    {
	        	Feature feature = featureIterator.next();
		        aLogger.info("Feature selected is : " +
feature.getAttribute("the_geom").toString());
		            
		    }
		}
        catch (Exception e)
        {
        	e.printStackTrace();
        }
        finally
        {
        	if (featureIterator != null)
        	{
        		featureIterator.close();
        	}
        }
        
        return features;
	}

If I just call the getFeatures() method - without the query, all the
features on that layer are returned correctly.  Any idea what I am doing
wrong?

Thanks again for taking the time to read this.

Pete Cornwell
-- 
View this message in context: http://www.nabble.com/Feature-Selection-using-example-tf3116329.html#a8632047
Sent from the udig-devel mailing list archive at Nabble.com.



Back to the top