Hi List,
I try to realise a dynamiv sld-file. Now I make a php file. The output of this
file is the sld description.
I think the output is ok.
Here are the code of the file.
<?php
$jahr=$HTTP_GET_VARS["jahr"];
$indikator=$HTTP_GET_VARS["indikator"];
$klassen=$HTTP_GET_VARS["klassen"];
// Öffnen der PostgreSQL DB
require("DB_Config.php");
// min und max für Klassengrenzen abfragen
require_once("minmax.php");
$mm = minMax($indikator,$jahr,$db);
$min = $mm[0];
$max = $mm[1];
$classified = 'daten';
$classMin = $min;
$classMax = $max;
$sld_spec = '<StyledLayerDescriptor version="1.0.0"
xmlns="http://www.opengis.net/sld"
xmlns:gml="http://www.opengis.net/gml"xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.opengis.net/sld
http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">';
$sld_layer_pre
='<NamedLayer><Name>gemeinden</Name><UserStyle><Title>
gemsee </Title> <FeatureTypeStyle>';
$sld_layer_post ='</FeatureTypeStyle>
</UserStyle> </NamedLayer> </StyledLayerDescriptor>';
$sld_first = '<Rule><Name>';
$sld_mid0 = '</Name> <Filter> <AND>
<PropertyIsEqualTo> <PropertyName>indikator</PropertyName>
<Literal>'.$indikator.'</Literal> </PropertyIsEqualTo>
<PropertyIsEqualTo> <PropertyName>jahr</PropertyName>
<Literal>'.$jahr.'</Literal> </PropertyIsEqualTo>
<PropertyIsBetween><PropertyName>'.$classified.'</PropertyName>
<LowerBoundary> <Literal>';
$sld_mid1 = '</Literal> </LowerBoundary>
<UpperBoundary> <Literal>';
$sld_mid2 = '</Literal> </UpperBoundary>
</PropertyIsBetween> </AND> </Filter>
<PolygonSymbolizer> <Fill> <CssParameter name="fill">';
$sld_last = '</CssParameter> <CssParameter
name="fill-opacity">1.00</CssParameter> </Fill> <Stroke>
<CssParameter name="stroke">#aa5500</CssParameter> </Stroke>
</PolygonSymbolizer> </Rule>';
$mysld =$sld_spec.$sld_layer_pre;
$schritt = ($classMax-$classMin)/$klassen;
$farbe = '#FF0000';
$first = true;
for ($i=0; $i<$klassen ;$i++) {
$lbound = $classMin + ($i*$schritt);
$ubound = $classMin + (($i+1)*$schritt);
$lb = round($lbound,2);
$ub = round($ubound,2);
$name1=$lb;
$name2=$ub;
$name = $name1 . ' ' . $name2;
if (!$first) {
$farbe2 = hexdec($farbe);
$farbe2 = $farbe2-11000;
$farbe = dechex($farbe2);
$farbe = "#".$farbe;
}
$mysld =
$mysld.$sld_first.$name.$sld_mid0.$lbound.$sld_mid1.$ubound.$sld_mid2.$farbe.$sld_last;
$first = false;
}
$mysld = $mysld.$sld_layer_post;
echo "$mysld";
?>
If I copy the output in an file and save it as *.sld. All works great with UMN
Mapserver with the GetMap Request.
http://localhost/cgi-bin/mapserv.exe?map=C:/ms4w/Apache/htdocs/Maps/Kanton_ZH_Gemeinden.map&SLD=http://localhost/ausgabe.sld&VERSION=1.1.0&REQUEST=GetMap&SERVICE=WMS&LAYERS=gemeinden&SRS=EPSG:4149&BBOX=640866.343701,215800.843324,745288.926741,291429.980390&WIDTH=914&HEIGHT=855&FORMAT=image/png&BGCOLOR=0xffffff&TRANSPARENT=TRUE&EXCEPTIONS=application/vnd.ogc.se_inimage
Now I will use it in OpenLayers. For this I use the following:
var map = new OpenLayers.Map('map',options);
var wms = new
OpenLayers.Layer.WMS("Gemeinden","http://localhost/cgi-bin/mapserv.exe?",
{map:"../htdocs/Maps/Kanton_ZH_Gemeinden.map",layers:"gemeinden",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile:
true} );
map.addLayer(wms);
wms.mergeNewParams({ SLD :
"mysld.php?jahr=2004&indikator=1&klassen=4" });
map.zoomToMaxExtent();
But it doesn't work. If I try to use the mysld.php file in the GetMap Request
it will not work, too.
I have no idea why it is so. Perhaps somebody can help me to find the mistake?
Thank you a lot for this.
Greetings
Hanno Rahn
------------------------------------------
Hanno Rahn, Dipl.-Ing. (FH) Geoinformatik
ZHAW Zürcher Hochschule für Angewandte Wissenschaften Umwelt und Natürliche
Ressourcen
Fachstelle Geoinformatik
Grüental, Postfach CH-8820 Wädenswil
Tel +41 (0)58 934 5592
Fax +41 (0)58 934 5580
[EMAIL PROTECTED]
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users