Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Filtering datas from a database

Hello Jacques,

you'll find a Layer.setFilter(Filter). This should work for you. But you
must set after

ApplicationGIS.addLayersToMap(ApplicationGIS.getActiveMap(),
 resourceList, 1, null, true);

and not in the loop. That is, when you have the layer. The effect should
be the same, however, only it's a higher level approach. udig would sort
the issues with the actual data store out.

You seem to be going too deep when you're asking for a OracleDataStore.
It'd be interesting to know whether there's any performance benefit from
this. (I guess not.)

Hope that helps.

Cheers,

Ugo

Jacques LESCOT said:
> Hi uDig'gers ! I am new on the uDig world and I am having some troubles
> while trying to filter some datas from an Oracle database.
>
> I have a database that consist of a set of tables : three of them
> contain spatial informations. I am able to retrieve the whole content of
> a given table, but now I would like to filter datas to be displayed on a
> map : particularly, I would like to filter only geometries corresponding
> to a given ID.
>
> Here is the snippet of code I got currently :
>
>     IServiceFactory factory =
> CatalogPlugin.getDefault().getServiceFactory();
>     for (IService service : factory.createService(params)) { // params
> is the map containing informations to connect to the database
>         if( service.canResolve(OracleDataStore.class )){
>             try {
>                 OracleDataStore database =
> service.resolve(OracleDataStore.class, new NullProgressMonitor());
>                 // This statement allows me to retrieve datas only for
> the LOCATION_POINT table ...
>                 FeatureSource<SimpleFeatureType, SimpleFeature>
> featureSource = database.getFeatureSource("LOCATION_POINT");
>                 // Add here filter [1]
>
>                 List<IGeoResource> resourceList = new
> ArrayList<IGeoResource>();
>                 for (IResolve nextElt : service.members(new
> NullProgressMonitor())) {
>                     if (nextElt instanceof IGeoResource) {
>                         resourceList.add((IGeoResource) nextElt);
>                     }
>                 }
>
> ApplicationGIS.addLayersToMap(ApplicationGIS.getActiveMap(),
> resourceList, 1, null, true);
>             } catch (Exception e) {
>                 e.printStackTrace();
>             }
>        }
>     }
>
> Then, I tried the following to only filter a particular row of my table :
>
>     // This code should go to the [1]
>     FilterFactory ff = new FilterFactoryImpl();
>     Filter myFilter =
> ff.id(Collections.singleton(ff.featureId("LOCATION_POINT.681")));
>
> ... but with no success :-/
>
> Any help would be appreciated.
>
> Regards,
> --
> Anyware Technologies <http://www.anyware-tech.com>
> *Jacques LESCOT*
> Project Manager
> Eclipse Technical Expert
> jacques.lescot@xxxxxxxxxxxxxxxx <mailto:jacques.lescot@xxxxxxxxxxxxxxxx>
> 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
>



Back to the top