Hi Lee Wai See,
I have recently been working with this as well. Alex Petkov has a
nice example: http://docs.codehaus.org/display/GEOSDOC/SLD+Snippets
Look at the bottom. If you take out the first named layer it will work
directly with the geoserver1.3.war demo/sampleRequest/ using the TestWfsPost
Also add the topp: prefix to states => topp:states
url:
http://localhost:8080/geoserver/wms/GetNap
body:
<?xml version="1.0" encoding="UTF-8"?>
<ogc:GetMap
xmlns:ogc="http://www.opengis.net/ows"
xmlns:gml="http://www.opengis.net/gml"
version="1.1.1" service="WMS">
<StyledLayerDescriptor version="1.0.0">
<NamedLayer>
<Name>topp:states</Name>
<NamedStyle>
<Name>population</Name>
</NamedStyle>
</NamedLayer>
</StyledLayerDescriptor>
<BoundingBox srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:coord>
<gml:X>-130.0</gml:X>
<gml:Y>24.0</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>-66.0</gml:X>
<gml:Y>50.0</gml:Y>
</gml:coord>
</BoundingBox>
<Output><Format>image/png</Format>
<Size>
<Width>600</Width>
<Height>320</Height>
</Size>
</Output>
<Exceptions>application/vnd.ogc.se+xml</Exceptions>
</ogc:GetMap>
I don't know the way mapbuilder works but here is a sample code for using
java to feed a custom sld to a wms/GetMap Post
Snippet:
try {
URL u = new URL("http://www.web-demographics.com/geoserver/wms/GetMap"\);
HttpURLConnection geocon = (HttpURLConnection)u.openConnection();
geocon.setAllowUserInteraction(false);
geocon.setRequestMethod("POST");
geocon.setRequestProperty("Content-Type", "application/xml");
geocon.setDoOutput(true);
geocon.setDoInput(true);
geocon.setUseCaches(false);
System.out.println("GetImage\n"+sld.toString());
xmlOut = new PrintWriter(new BufferedWriter(new
OutputStreamWriter(geocon.getOutputStream())));
xmlOut.write(sld.toString());
xmlOut.flush();
xmlOut.close();
response.setHeader("Cache-Control", "no-store, no-cache,
must-revalidate");
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
response.setHeader("Pragma", "no-cache");
response.setContentType("image/jpeg");
OutputStream outsld = response.getOutputStream();
int c;
InputStream in = geocon.getInputStream();
while ((c = in.read()) != -1) outsld.write(c);
in.close();
outsld.close();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
System.out.println("WMSFeature: "+e.toString());
}
Here is another example sld for filtering by bounding box and parameter
value:
<?xml version="1.0" encoding="UTF-8"?>
<ogc:GetMap
xmlns:ogc="http://www.opengis.net/ows"
xmlns:gml="http://www.opengis.net/gml"
version="1.1.1" service="WMS">
<StyledLayerDescriptor version="1.0.0">
<NamedLayer>
<Name>geo:USGS_Quat_Faults</Name>
<UserStyle>
<Name>geothermalgeo:USGS_Quat_Faults</Name>
<Title>Geothermal</Title>
<Abstract>Geothermal filters</Abstract>
<FeatureTypeStyle>
<Rule>
<!-- Theme 1 -->
<ogc:Filter xmlns:gml="http://www.opengis.net/gml">
<ogc:PropertyIsBetween>
<ogc:PropertyName>SLIPRATE</ogc:PropertyName>
<ogc:LowerBoundary>
<ogc:Literal>0.001</ogc:Literal>
</ogc:LowerBoundary>
<ogc:UpperBoundary>
<ogc:Literal>17.5005</ogc:Literal>
</ogc:UpperBoundary>
</ogc:PropertyIsBetween>
</ogc:Filter>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">
<ogc:Literal>#0000FF</ogc:Literal>
</CssParameter>
<CssParameter name="stroke-width">
<ogc:Literal>2</ogc:Literal>
</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
<Rule>
<!-- Theme 2 -->
<ogc:Filter xmlns:gml="http://www.opengis.net/gml">
<ogc:PropertyIsBetween>
<ogc:PropertyName>SLIPRATE</ogc:PropertyName>
<ogc:LowerBoundary>
<ogc:Literal>17.5005</ogc:Literal>
</ogc:LowerBoundary>
<ogc:UpperBoundary>
<ogc:Literal>35</ogc:Literal>
</ogc:UpperBoundary>
</ogc:PropertyIsBetween>
</ogc:Filter>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">
<ogc:Literal>#FF0000</ogc:Literal>
</CssParameter>
<CssParameter name="stroke-width">
<ogc:Literal>2</ogc:Literal>
</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
<BoundingBox srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:coord>
<gml:X>-116.01796340942383</gml:X>
<gml:Y>36.40119743347168</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>-114.8682632446289</gml:X>
<gml:Y>37.33532905578613</gml:Y>
</gml:coord>
</BoundingBox>
<Output><Format>image/jpeg</Format>
<Size>
<Width>1000</Width>
<Height>813</Height>
</Size>
</Output>
<Exceptions>application/vnd.ogc.se+xml</Exceptions>
</ogc:GetMap>
Hope this helps
Rkgeorge
-----Original Message-----
From: geoserver-users-admin@lists.sourceforge.net
[mailto:geoserver-users-admin@lists.sourceforge.net] On Behalf Of Lee Wai
See
Sent: Friday, February 24, 2006 12:35 AM
To: 'Brent Owens'
Cc: geoserver-users@lists.sourceforge.net
Subject: RE: [Geoserver-users] RE: Adding the SLD body dynamically
Hi Brent,
Thank you for your reply. Pardon me, but the SLD-POST link under the URL you
have given to me does not contain any information. Could you please point
out to me where I can get relevant information to help in the implementation
of my desired feature as described? Thank you.
Regards,
Lee Wai See
ST Electronics (Info-Software Systems) Pte Ltd
-----Original Message-----
From: geoserver-users-admin@lists.sourceforge.net
[mailto:geoserver-users-admin@lists.sourceforge.net] On Behalf Of Brent
Owens
Sent: Friday, February 24, 2006 3:24 PM
To: Lee Wai See
Cc: geoserver-users@lists.sourceforge.net
Subject: Re: [Geoserver-users] RE: Adding the SLD body dynamically
You should be able to do something like that using SLD-POST. There is
some information on SLDs here:
http://docs.codehaus.org/display/GEOSDOC/SLD%20Explanations%20and%20Samples
It is a good starting point.
Brent Owens
(The Open Planning Project)
Lee Wai See wrote:
Hi,
I want to add the SLD body of the map dynamically rather than
statically through the context.xml file. That is, I want to display
not all, but only some of the features, of a map layer depending on
the input from the user. Can anyone be kind enough to give advice on
how this can be done in GeoServer ands MapBuilder?
Hope I am clear in my question. Thanks.
Regards,
Lee Wai See
ST Electronics (Info-Software Systems) Pte Ltd
[This e-mail is confidential and may be priviledged. If you are not the
intended recipient, please kindly notify us immediately and delete the
message
from your system; please do not copy or use it for any purpose, nor
disclose
its contents to any other person. Thank you.]
---ST Electronics Group---
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users