[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [udig-devel] Accessing selected feature attributes
|
No no it should be using the usename that you entered in the wizard
dialog.
Jesse
On 11-Jan-07, at 5:34 PM, Murray Richardson wrote:
You mean it's using my windows username at this point, even though the
initial connection was made with the default postgres account? It's
weird - I tried changing rights on the relevant DB and
geometry_columns
table to match my OS username but not effect. Ah well - it's not that
critical right now.
The code snippet is very helpful...
cheers
Murray
Jesse Eichar wrote:
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)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
---------------------------------------------------------------------
---
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
---------------------------------------------------------------------
---
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.16.9/622 - Release Date:
1/10/2007 2:52 PM
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel