[Geoserver-users] Run SQL join query on Oracle through GeoServer

Good afternoon

I have to run dynamic queries on my Oracle database to join statistical data
and geographical data.
One table contains statistical data and the other geometry. The result table
should be then used by Geoserver in order to generate a map.
My idea to run these queries through GeoServer and then display the
resulting table containing geometry.
Is it possible, how can i do that?

Many thanks for your help

Sylvain
--
View this message in context: http://www.nabble.com/Run-SQL-join-query-on-Oracle-through-GeoServer-tp17230606p17230606.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Hi Sylvain,

GeoServer doesn't support sending arbitrary SQL requests to databases. I think for this you would need to have your own custom code create the views in the database and then add them as new featuretypes in GeoServer. Unfortunately automated configuration of GeoServer is not very well supported right now. There is some example code on the wiki at http://geoserver.org/display/GEOSDOC/Alternative+for+reloading+the+Geoserver+catalog for how to force a configuration reload after fixing up the configuration files to add a new datastore. There is also work underway on a REST API which should make this sort of thing much easier, but it's pretty unpolished at this point. (see http://geoserver.org/display/GEOSDOC/GeoServer+Resources)

Hope this helps,
David Winslow

springrider wrote:

Good afternoon

I have to run dynamic queries (SELECT..) on my Oracle database to extract
data. They will be done on a view which contains both statistical and
geographical.
The result should be then used by Geoserver 1.6.3 in order to generate a map
based on a specific sld (quantile classification) showing value associated
to each square of a grid.
My idea is to run these SQL queries against my DB through GeoServer. Is it possible, how can i do that?

Many thanks for your help

Sylvain
  

springrider ha scritto:

Good afternoon

I have to run dynamic queries (SELECT..) on my Oracle database to extract
data. They will be done on a view which contains both statistical and
geographical.
The result should be then used by Geoserver 1.6.3 in order to generate a map
based on a specific sld (quantile classification) showing value associated
to each square of a grid.
My idea is to run these SQL queries against my DB through GeoServer. Is it possible, how can i do that?

Adding to what David already said, if you just need to perform
simple filters and attribute extraction, have a look at the
custom filter extensions (not part of the WMS standard) here:
http://geoserver.org/display/GEOSDOC/WMS+vendor+parameters

For example, USA map here:
http://sigma.openplans.org/geoserver/wms?WIDTH=800&SRS=EPSG%3A4326&LAYERS=topp%3Astates&HEIGHT=317&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&BBOX=-145.48948729687498,17.494455975488286,-46.21178370312501,56.833246024511716
and just New York state here:
http://sigma.openplans.org/geoserver/wms?WIDTH=800&SRS=EPSG%3A4326&LAYERS=topp%3Astates&HEIGHT=317&STYLES=&FORMAT=image%2Fpng&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&BBOX=-145.48948729687498,17.494455975488286,-46.21178370312501,56.833246024511716&cql_filter=STATE_NAME%20=%20'New%20York'

where the filter is: &cql_filter=STATE_NAME%20=%20%27New%20York%27

Cheers
Andrea

Hi David,

http://geoserver.org/display/GEOSDOC/GeoServer+Resources

very interesting to me too. But I couldn't get it work or I don't understand
the table. If I make a request like
http://localhost:8080/geoserver/projections I should get a list of the
projections?! My GS 1.6.3 returns just a 404 not found :frowning:

Greetings,

Tilo

Tilo Wutherich ha scritto:

Hi David,

http://geoserver.org/display/GEOSDOC/GeoServer+Resources

very interesting to me too. But I couldn't get it work or I don't understand
the table. If I make a request like
http://localhost:8080/geoserver/projections I should get a list of the
projections?! My GS 1.6.3 returns just a 404 not found :frowning:

" There is also work underway
on a REST API which should make this sort of thing much easier, but it's
pretty unpolished at this point. (see
http://geoserver.org/display/GEOSDOC/GeoServer+Resources)"

By underway he really meant incomplete, not there. In fact we don't ship geoserver with it, months will pass before we ship with a REST api
officially included in the GeoServer releases.

Cheers
Andrea

Thanks for your answer

This is the URL of the application i try to redevelop:
http://www.fao.org/figis/servlet/TabSelector.
It involves generating a map based on on user request.

In my configuration, I have now created a view in my Oracle database which
contains both Geographical and statistical values which has been added as a
featuretype in Geoserver.

I am not sure to well understand what your are sayingy "You have to create
the views and add them in Geoserver". Do you mean created a view for each
user request?

The point is that the query which is made against this view is different
acording to the user. It implies that the query result is unique to each
user and should be then be exploited by GeoServer to generate a map.

I succeed running some very simple queries on that fetauretype using
Ogc:Filter but i am lost when trying to write a more complex query.

Example:

This is the content of my view:

Geometry_|_ID_GEO_|_Year_|_Value
Polygon1_|__1______|_1999_|__5
Polygon1_|__1______|_1999_|__7
Polygon2_|__2______|_1999_|__4
Polygon2_|__2______|_1999_|__12

I want to get the sum of the value for the year 1999 for each ploygon to
obtain something like that:

Geometry_|_ID_GEO_|_Year_|_Value
Polygon1_|__1______|_1999_|__12
Polygon2_|__2______|_1999_|__16

I know that the SQL statement should be something like that:
SELECT Geometry,SUM(Value),ID_GEO FROM MyTable WHERE Year=1999 GROUP BY
ID_GEO but i don't know how to obtain this kind of query applying on my
featuretype by using ogc:filter.

Do you think it could work? Could i send the SQL query by code to the DB and
then use the result in Geoserver in order to generate a map?

The idea is to send through URL or other the query to the DB to get a result
directly usable by Geoserver. So it implies to include GeoServer in the
process such as having the view declared as a featuretype and running the
query through it, doesn't it?

I hope it is clear enough.

Many thanks for your help

Sylvain

David Winslow-3 wrote:

Hi Sylvain,

GeoServer doesn't support sending arbitrary SQL requests to databases.
I think for this you would need to have your own custom code create the
views in the database and then add them as new featuretypes in
GeoServer. Unfortunately automated configuration of GeoServer is not
very well supported right now. There is some example code on the wiki
at
http://geoserver.org/display/GEOSDOC/Alternative+for+reloading+the+Geoserver+catalog
for how to force a configuration reload after fixing up the
configuration files to add a new datastore. There is also work underway
on a REST API which should make this sort of thing much easier, but it's
pretty unpolished at this point. (see
http://geoserver.org/display/GEOSDOC/GeoServer+Resources)

Hope this helps,
David Winslow

springrider wrote:

Good afternoon

I have to run dynamic queries (SELECT..) on my Oracle database to extract
data. They will be done on a view which contains both statistical and
geographical.
The result should be then used by Geoserver 1.6.3 in order to generate a
map
based on a specific sld (quantile classification) showing value
associated
to each square of a grid.
My idea is to run these SQL queries against my DB through GeoServer.
Is it possible, how can i do that?

Many thanks for your help

Sylvain
  
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
View this message in context: http://www.nabble.com/Run-SQL-query-on-Oracle-through-GeoServer-tp17230606p17254756.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

Hi Sylvain,

This should be easy enough to do with a view. Just create the view in the database and then add the view to geoserver as you would a regular table. One caveat though, you will have to manually add a geometry_columns entry for the view.

-Justin

springrider wrote:

Good afternoon

I have to run dynamic queries on my Oracle database to join statistical data
and geographical data.
One table contains statistical data and the other geometry. The result table
should be then used by Geoserver in order to generate a map.
My idea to run these queries through GeoServer and then display the
resulting table containing geometry. Is it possible, how can i do that?

Many thanks for your help

Sylvain

--
Justin Deoliveira
The Open Planning Project
jdeolive@anonymised.com

Doh, apparently i missed "Oracle" in the subject header :). Apologies.

Andrea: does GeoServer work with oracle views like it does with postGIS?

Justin Deoliveira wrote:

Hi Sylvain,

This should be easy enough to do with a view. Just create the view in the database and then add the view to geoserver as you would a regular table. One caveat though, you will have to manually add a geometry_columns entry for the view.

-Justin

springrider wrote:

Good afternoon

I have to run dynamic queries on my Oracle database to join statistical data
and geographical data.
One table contains statistical data and the other geometry. The result table
should be then used by Geoserver in order to generate a map.
My idea to run these queries through GeoServer and then display the
resulting table containing geometry. Is it possible, how can i do that?

Many thanks for your help

Sylvain

--
Justin Deoliveira
The Open Planning Project
jdeolive@anonymised.com

Justin Deoliveira ha scritto:

Doh, apparently i missed "Oracle" in the subject header :). Apologies.

Andrea: does GeoServer work with oracle views like it does with postGIS?

I believe so, but I've never tried personally.
The Oracle page in the user guide has an example thought:
http://geoserver.org/display/GEOSDOC/Oracle+DataStore

Cheers
Andrea

Hi,

Andrea: does GeoServer work with oracle views like it does with postGIS?

I believe so, but I've never tried personally.
The Oracle page in the user guide has an example thought:
http://geoserver.org/display/GEOSDOC/Oracle+DataStore

Geoserver works with Oracle views. I believe, though, that it is possible to create a view that does not work, for example if it does not have any unique column. For sure the view can be extremely slow if the database is not tuned for the query behind that but it is the same with any database. Naturally a view must have a reference in SDO_GEOM_METADATA.

-Jukka Rahkonen-

I confirm that connecting Oracle views works in GeoServer. You need to have a
Geometry field in your view and to declare it in SDO_GEOM_METADATA table.
My main problem is now to generate these views dynamically for each user
making a query and attach them to GeoServer.

Thanks

Sylvain

Rahkonen Jukka wrote:

Hi,

Andrea: does GeoServer work with oracle views like it does with postGIS?

I believe so, but I've never tried personally.
The Oracle page in the user guide has an example thought:
http://geoserver.org/display/GEOSDOC/Oracle+DataStore

Geoserver works with Oracle views. I believe, though, that it is possible
to create a view that does not work, for example if it does not have any
unique column. For sure the view can be extremely slow if the database is
not tuned for the query behind that but it is the same with any database.
Naturally a view must have a reference in SDO_GEOM_METADATA.

-Jukka Rahkonen-

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
View this message in context: http://www.nabble.com/Run-SQL-query-on-Oracle-through-GeoServer-tp17230606p17364166.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

springrider ha scritto:

I confirm that connecting Oracle views works in GeoServer. You need to have a
Geometry field in your view and to declare it in SDO_GEOM_METADATA table.
My main problem is now to generate these views dynamically for each user
making a query and attach them to GeoServer.

If you're looking for ways to keep a view registered and available
for a single user, maybe linked to his sessions, I fear we don't have
any.

What you can do is to alter dynamically the GeoServer configuration
mimicking what a user would do when using the web admin UI
(http://geoserver.org/display/GEOSDOC/Alternative+for+reloading+the+Geoserver+catalog)
or using the unsupported RESTConfig module (David, do we have any
documentation on how to use it?).

REST api is going to become supported in GeoServer 1.7.0, so from
there on we'll have some decent way of programmatically alter
the catalog, but so far, we don't have much else

Cheers
Andrea

All the documentation for the RESTConfig module lives on the GeoServer wiki at http://geoserver.org/display/GEOSDOC/RESTful+Configuration+API . There's unfortunately no description of the formats for request bodies, but in general they correspond to forms on the current configuration UI. To build with RESTConfig, all that's needed is 'mvn install -Prest,RESTConfig' . The trunk version is probably less buggy than what's in 1.6.x but neither is completely functional. Unfortunately the version in trunk doesn't compile against 1.6.x so some work would be needed to port it. However, I believe configuring and de-configuring featuretypes should be working.

Hope this helps,
David Winslow

Andrea Aime wrote:

springrider ha scritto:

I confirm that connecting Oracle views works in GeoServer. You need to have a
Geometry field in your view and to declare it in SDO_GEOM_METADATA table.
My main problem is now to generate these views dynamically for each user
making a query and attach them to GeoServer.

If you're looking for ways to keep a view registered and available
for a single user, maybe linked to his sessions, I fear we don't have
any.

What you can do is to alter dynamically the GeoServer configuration
mimicking what a user would do when using the web admin UI
(http://geoserver.org/display/GEOSDOC/Alternative+for+reloading+the+Geoserver+catalog)

or using the unsupported RESTConfig module (David, do we have any
documentation on how to use it?).

REST api is going to become supported in GeoServer 1.7.0, so from
there on we'll have some decent way of programmatically alter
the catalog, but so far, we don't have much else

Cheers
Andrea

!DSPAM:4040,4836983176927082231907!