[Geoserver-devel] Geoserver SQL View Layers + SLD_BODY ?

Hello,

The Geoserver version 2.1 onwards, provides support to so called Layers SQL
View, where you can create SQL statements with parameters pointing to a
PostGIS (for example). Using OpenLayers, wms can create dynamic layers from
a sql command using the parameter viewparams. Example:

var wms = new OpenLayers.Layer.WMS.Post ("Test View", "/ GeoServer / wms",
{layers: 'censoibge: test', format: 'image / gif', transparent: "true",
style: style }, options);

var str = "(culture = 'Soja' and year = 2009 and area_plantada>
area_plantada 100 and <= 1000 and area_plantada <> 0) or";
   str + = "(culture = 'Soja' and year = 2009 and area_plantada>
area_plantada 1000 and <= 2000) or";
   str + = "(culture = 'Soja' and year = 2009 and area_plantada>
area_plantada 2000 and <= 3000) or";
   str + = "(culture = 'Soja' and year = 2009 and area_plantada>
area_plantada 3000 and <= 4000) or";
   str + = "(culture = 'Soja' and year = 2009 and area_plantada>
area_plantada 4000 and <= 5000) or";
   str + = "(culture = 'Soja' and year = 2009 and area_plantada>
area_plantada 5000 and <= 10000) or";
   str + = "(culture = 'Soja' and year = 2009 and area_plantada> 10000)";
    
wms.mergeNewParams ({
viewparams "sql: select * from where vw_pam_all_shapes" + str
  });

The problem is when I try to set a sld_body to implement different styles
for each condition. Testing sld_body in a normal layer (not SQL type VIEW)
everything works ok, but if I do:

wms.mergeNewParams ({
sld_body: sld
});

the layer styles and does not respect the rules defined in SLD.

Can anyone help? There is the possibility of applying layers sld_body in the
sql view Geoserver? If not, there is another alternative that allows the
flexibility to open the setting styles for the user?

Thank you.

--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Geoserver-SQL-View-Layers-SLD-BODY-tp6666737p6666737.html
Sent from the GeoServer - Dev mailing list archive at Nabble.com.

On Mon, Aug 8, 2011 at 11:14 PM, Davi Custódio [via OSGeo.org] <[hidden email]> wrote:

Hello,

The Geoserver version 2.1 onwards, provides support to so called Layers SQL View, where you can create SQL statements with parameters pointing to a PostGIS (for example). Using OpenLayers, wms can create dynamic layers from a sql command using the parameter viewparams. Example:

var wms = new OpenLayers.Layer.WMS.Post (“Test View”, “/ GeoServer / wms”, {layers: ‘censoibge: test’, format: ‘image / gif’, transparent: “true”, style: style }, options);

var str = “(culture = ‘Soja’ and year = 2009 and area_plantada> area_plantada 100 and <= 1000 and area_plantada <> 0) or”;
str + = “(culture = ‘Soja’ and year = 2009 and area_plantada> area_plantada 1000 and <= 2000) or”;
str + = “(culture = ‘Soja’ and year = 2009 and area_plantada> area_plantada 2000 and <= 3000) or”;
str + = “(culture = ‘Soja’ and year = 2009 and area_plantada> area_plantada 3000 and <= 4000) or”;
str + = “(culture = ‘Soja’ and year = 2009 and area_plantada> area_plantada 4000 and <= 5000) or”;
str + = “(culture = ‘Soja’ and year = 2009 and area_plantada> area_plantada 5000 and <= 10000) or”;
str + = “(culture = ‘Soja’ and year = 2009 and area_plantada> 10000)”;

wms.mergeNewParams ({
viewparams “sql: select * from where vw_pam_all_shapes” + str
});

The problem is when I try to set a sld_body to implement different styles for each condition. Testing sld_body in a normal layer (not SQL type VIEW) everything works ok, but if I do:

wms.mergeNewParams ({
sld_body: sld
});

the layer styles and does not respect the rules defined in SLD.

Can anyone help? There is the possibility of applying layers sld_body in the sql view Geoserver? If not, there is another alternative that allows the flexibility to open the setting styles for the user?

Thank you.


If you reply to this email, your message will be added to the discussion below:
http://osgeo-org.1803224.n2.nabble.com/Geoserver-SQL-View-Layers-SLD-BODY-tp6666737p6666737.html
To start a new topic under GeoServer - Dev, email [hidden email]
To unsubscribe from GeoServer - Dev, click here.


Davi de O. Custódio


View this message in context: Re: Geoserver SQL View Layers + SLD_BODY ?
Sent from the GeoServer - Dev mailing list archive at Nabble.com.

On Tue, Aug 9, 2011 at 4:14 AM, Davi Custódio <Davicustodio@anonymised.com> wrote:

Hello,

The Geoserver version 2.1 onwards, provides support to so called Layers SQL
View, where you can create SQL statements with parameters pointing to a
PostGIS (for example). Using OpenLayers, wms can create dynamic layers from
a sql command using the parameter viewparams. Example:

There is no need to explain what sql views are.
Anyways, you're posting to the wrong mailing list, the devel list is there for
developers to talk with each other.
You are a developer if you are trying to contribute code or documentation
to GeoServer.
If you're not, please ask on the users list

Btw, you'll have to provide more information, less introduction to what can
be found in a user guide already (what sql view are) and more details on
your request, such as the sql view definition, the contents of the SLD_BODY,
and the full request you're using

It is also easier to help you if you post the actual requests sent to GeoServer
instead of providing OL samples, not all developers use javascript clients
(some, like me, just never do, I have coworkers that specialize on that).

Cheers
Andrea

--
-------------------------------------------------------
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead

Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy

phone: +39 0584 962313
fax: +39 0584 962313

http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf

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