Jesse Eichar wrote:
They way that I shows will be a bit nicer because the map is open and if you add the layer before setting the filter a request will be made to get the features which will have to be cancelled and a new request made. My snippet ensures that the request is made only once.

All right! Thanks for pointing it out.

Ugo


Jesse

On 19-Dec-08, at 12:17 PM, Ugo Taddei wrote:

Hi,

this is easier than you think :-)

Forget the OracleDataStore and the Filter stuff in the following loop. Just do this:

List resourceList = instantiate...

for( IService service : serviceFactory.createService( params ) ){
    try {
        CatalogPlugin.getDefault().getLocalCatalog().add( service );

        for (IResolve nextElt : service.members(new
                if (nextElt instanceof IGeoResource) {
                   resourceList.add((IGeoResource) nextElt);
                }
            }

    }catch (IOException couldNotConnect ){
      //log
    }
}


//add to the map
ApplicationGIS.addLayersToMap(ApplicationGIS.getActiveMap(),
resourceList, 1, null, true);

//now get the layers and apply the filter with the blacboard snippet
// from the previous email

Here you just plugin the code Jesse just sent.


Jacques LESCOT wrote:
Maybe that my problem is different :
Using the following code snippet, the "coll" variable contains indeed the only Feature with the given ID. The probem is that I do not know how to either enforce this filter to be applied to my IService or adapt teh Feature into an IGeoResource so that it could be displayed on a Layer ? OracleDataStore database = service.resolve(OracleDataStore.class, new NullProgressMonitor()); FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = database.getFeatureSource("LOCATION_POINT"); // Filter only the LOCATION_POINT table from my database FilterFactory ff = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints()); Filter franceFilter = ff.id(Collections.singleton(ff.featureId("LOCATION_POINT.681"))); FeatureCollection<SimpleFeatureType, SimpleFeature> coll = featureSource.getFeatures(franceFilter); // Filter only the record with ID="681" List<IGeoResource> resourceList = new ArrayList<IGeoResource>(); for (IResolve nextElt : service.members(new NullProgressMonitor())) { // service.members(...) returns me the whole LOCATION_POINT table
                       if (nextElt instanceof IGeoResource) {
                           resourceList.add((IGeoResource) nextElt);
                       }
                   }
ApplicationGIS.addLayersToMap(ApplicationGIS.getActiveMap(), resourceList, 1, null, true); I added some comments in order to help you understand what's happen with the above code. Thus, I am here working with an OracleDataStore, and I am using uDig trunk source code.
Regards,
Jacques
Ugo Taddei a écrit :
Jesse Eichar wrote:

On 19-Dec-08, at 11:32 AM, Jacques LESCOT wrote:

See my comments below,

Jesse Eichar a écrit :

Hi,

We need to rename the packages from internal to something less frightening. When it comes to net.refractions.udig.project the internal packages can be used but NOT the internal.impl packages. The idea was to make people reluctant to use the internal classes because most of the things should be done with Commands not direct. Commands allow roll-back. Problem was that for setting up maps and so on it is annoying to do it through commands.
Yes, I recognized here EMF behavior :-)

As for filtering features I would recommend trying to make use of the view work.
In my case, I need to perform this programmatically.
It has a couple bugs but in general works. The way to do it is to put a Filter on the styleblackboard with the key: net.refractions.udig.project.ProjectBlackboardConstants.ProjectBlackboardConstants.LAYER__DATA_QUERY
You will probably think I am fastidious but I would prefer a solution where filtering is done at a upper level : I mean instead of retrieving all the datas from the database and then filtering them in the map editor, I would like to filter things when requesting datas from the database. As I said before, the database may contains lots of records and thus it would be more judicious to limit records that are sent back by the server. I am pretty sure solution is near (from what I read from http://docs.codehaus.org/display/GEOTDOC/02+Filter) but I would really need a little more help. :-)

Huh. I thought it created it did something so that only those features that matched the Filter were retrieved. I haven't personally tested this but that was my understanding. Have you verified that all features are retrieved from the postgis? You are using Postgis right?

I think you're correct here, Jesse. The filtering is done at data store level. Though I haven't written the code in our app, the colleague who did told me it was so. (At least with our shapefiles. And that was udig 1.1, but I don't think that should matter.)

Cheers,

Ugo



------------------------------------------------------------------------

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


--
Anyware Technologies <http://www.anyware-tech.com> *Jacques LESCOT*
Project Manager
Eclipse Technical Expert
[email protected] <mailto:[email protected]>
Standard : +33(0)5 61 00 52 90
Direct : +33(0)5 61 00 06 60
Mobile : +33(0)6 74 49 23 34
Fax : +33(0)5 61 00 51 46     *Anyware Technologies
* Lake Park
ZAC de l'Hers - Allée du Lac
BP 87216
31672 Labège Cedex
France
www.anyware-tech.com <http://www.anyware-tech.com>
This message and any attachments (the "Message") are confidential and intended solely for the addressees. Any unauthorized modification, edition, use or dissemination is prohibited. Neither Anyware Technologies nor its headquarters Wavecom shall be liable for the Message if altered, changed, falsified or edited, diffused without authorization.
------------------------------------------------------------------------
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel


--
Ugo Taddei

Fraunhofer Institut Intelligente Analyse- und Informationssysteme (FhG IAIS)
http://www.iais.fraunhofer.de
Department Knowledge Discovery - IAIS.KD -
Working Group Spatial Decision Support
http://www.iais.fraunhofer.de/kd.html
phone  (+49)2241-14-2184    fax    (+49)2241-14-2072
Schloss Birlinghoven, D-53754 Sankt Augustin, Germany
_______________________________________________
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





--
Ugo Taddei

Fraunhofer Institut Intelligente Analyse- und Informationssysteme (FhG IAIS)
http://www.iais.fraunhofer.de
Department Knowledge Discovery - IAIS.KD -
Working Group Spatial Decision Support
http://www.iais.fraunhofer.de/kd.html
phone  (+49)2241-14-2184    fax    (+49)2241-14-2072
Schloss Birlinghoven, D-53754 Sankt Augustin, Germany
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

Reply via email to