On 11-Jan-07, at 1:57 PM, Murray Richardson wrote:
Jesse or others,
A couple quick questions for you:
(1) Is there a simple way to return attributes (say FID) for all selected features in a layer?  I would like to use these values in statements to postgreSQL.  I'm not clear on how to get them from the Layer Filter.
To get the selected features:    
Suppose you just want the FID:        
        ILayer layer=null;
        // first create a query that restricts the attributes returned.  Since we just want the FID then we don't need
        // any attributes because that is not an attribute it part of the Feature itself.
        // also use the Layer.getFilter() method to return the selected features.
        // the new String[0] parameter indicates that we don't want any attributes.  We could have put an attribute/column 
        // name to indicate the attributes that we want.
        Query query = new DefaultQuery(layer.getSchema().getTypeName(), layer.getFilter(), new String[0]);
        
        IProgressMonitor monitor;
        FeatureSource featureSource = layer.getResource(FeatureSource.class, monitor);
        FeatureCollection features = featureSource.getFeatures(query);
        FeatureIterator featureIterator = features.features();
        try{
            while(featureIterator.hasNext() ){
                Feature feature=featureIterator.next();
                
                // do something.
				  // the features here will have no attributes or geometry but you can call getID().
				  // warning you can't call getBounds() cause there's no geometry.  this is a bug that still needs to be fixed
            }
            
        }finally{
            // don't forget to close the iterator...
            featureIterator.close();
        }
Here's an example of a Query that requests the attribute called streetname:
        Query query = new DefaultQuery(layer.getSchema().getTypeName(), layer.getFilter(), new String[]{streername});     
 
(2) Create Feature Type operation doesn't work on the postGISdataStore that I access through my postGIS host in the catalog tree.  I get a "Failed to create Feature Type" error.  This could be handy.  Is there a simple solution?
Are you talking about the operation that you get when you right-click on a PostGis in the catalog?  If so this probably means that as a user you don't have the access to make a feature type.  I have tested it before and it does work, but it does require permission to create tables and to modify the Geomtrycolumns table.  I don't know if it works on pre 8.1 versions of Postgres.  
Thanks,
Murray
_______________________________________________
User-friendly Desktop Internet GIS (uDig)