Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Exploring uDIG: from a map selection to a database query



alain.demers@xxxxxxxxxxxxxxxx wrote:

Hi,

Congratulation for uDIG, it is a great tool that I discover with enthusiasm. I am trying to find my way in the javadoc (uDIG and GeoTools), which are huge. To understand uDIG plug-in creation, I try to create a real case. Here my scheme of work (my trouble is in the #4):

Your list always begins with "1." :-)

   1. Make a selection on a layer.

This is a user interface operation with the use of selection tool- no code here

Behind the scenes a GeoTools Filter indicating the selection is stored for each Layer. The selection tool lets you modify this Filter. If someone has time a dialog could also be created to let people manually indicate the selection.

   1. Read the filter of the selection of this layer.

I use PostGIS. I have a Geometry table which is link to huge schema including many descriptive tables. Geometries are points where I have information on fish or fish habitat. One point may include many information types (fish inventory, habitats, species observations, etc.). I know the layer name which is my Geometry Table. I retrieve my Layer with PlatformGIS. getActiveMap().getMapLayers(). I can make a check to find the layer to catch the filter with getFilter() on this layer. I want to use this filter to select the descriptive information in my database.

You should be able to ask for the FeatureSource associated with the Layer, and then you can use normal geotools code to access.

(I am doing this from memory so may need correction)

FeatureSource data = layer.getResource( FeatureSource.class );
data.getFeatures( layer.getFilter() );

   1. Read the source of the data of the layer.

I can find the URL for the same layer

If you ask the the way in which you want to see the data (using getResource above) we will be use any metadata around to help out at the framework level. As an example sometimes a WMS Layer has a data url which we may be able to use to find a WFS etc ...

   1. Make a collection to create an Iterator.

Here is my trouble, is it the right way if I try to create a FeatureCollection from a FeatureSource? How should I link a FeatureSource to a Layer? I guess that there is another way than FeatureSource...

The layer should already be defined by a FeatureSource ... Question: are you defining your Layer as a program or is the user defining the layer which you are then operating with?

   1. Make a View (in PostGresSQL and Udig) to explore the data based
      on the Iterator.

I am not here yet, do you have a suggestion

Making a view is kind of tough, and is a subject of research in the geotools library right now. Right now a datastore *can* show the database defined views - the result should be returned as a read-only FeatureSource. So the suggestion is - define your view on the database side, and read it through geotools.

Jody



Back to the top