Proof of Concept
- I’m using Sahana version 0.6.2 stable release
- Sahana read the configuration from MySQL and then file configuration. So, we have to change all configuration in config values (Administration > Config Utils > Config Values) and then edit conf.inc file.
- Sahana only provides 2 layers in openlayers (this is the default configuration). You can see this in Config Values, if we want more layers, we should add manually in conf.inc file.
- Sahana produce a map in JPG format. We all know that JPG does not support transparency, so we should change this with PNG. We will adding some PHP codes in openlayers_fns.php.
Adding More than 2 Layers
Check Config Values (administration > Config Utils > Config Values) and find this line:
ol_wms
Change this with your own. lets try 5 for this. It mean’s there are 5 layers will be shown in openlayers. first layer is a based layer and the others become an overlay layers.
Second, find this line at Config Values (Administration > Config Utils > Config Values):
ol_wms_1_layers
.......
.......
.......
ol_wms_2_url
Focus to this line :
ol_wms_1_layers (fill with layer name, this is a based layer)
ol_wms_1_transparency (fill with 0)
ol_wms_1_url (fill with WMS URL)
ol_wms_2_layers (fill with layer name)
ol_wms_2_transparency (fill with 1)
ol_wms_2_url (fill with WMS URL)
As i wrote before, sahana only provides 2 layers. If we want to add more than 2 layers then we should add them manually.
Now, we have to edit conf.inc. Find this line:
$conf['ol_wms_1_description'] = '';
.............
.............
$conf['ol_wms_2_max'] = '';
Copy and change the [2]’s part (duplicating to 5) and fill with your own. See this example.
Modified Openlayers_fns.php
Now we will add some php codes and ‘hack’ openlayers_fns.php file. We have to modified cause this file produce a map in JPG format and we will change to PNG. See this file.
Go to line 121 openlayers_fns.php file and you will see this:
echo "var wmslayer$i = new OpenLayers.Layer.WMS( \"$name\",\n";
echo "\"$url\",\n";
echo "{layers: '$layers'} );\n";
Change with this one:
echo "var wmslayer$i = new OpenLayers.Layer.WMS( \"$name\",\n";
echo "\"$url\",\n";
if($conf["ol_wms_".$i."_transparency"] == 1) { $trans = ", transparent: \"true\""; }
echo "{layers: '$layers' $trans , format: \"image/png\"} );\n";
This new code will produce a map in PNG format.
Save that file, login to Sahana and check your maps. This is the result.
Hope that helps.
Pencerahan langsung dari masternya ^^, thx mas Dudi. Minta ijin dicomot step-stepnya buat ditaro di wiki iosn-fossgis yaks.
kalo ada yang kurang step-nya ditambahin lagi ya dik, soalnya itu juga ngebut ngerjainnya
Hi Dudi,
Nice info. I created the OL plugin along with Fran Boon for Sahana.. and yes, we did limit it to 2 layers at the time…
Anyways, we’re now working on a layer catalog module: an admin module to manage the OL layers, where we can dynamically add any number of layers.. this is work in progress at the moment, but should be completed pretty soon. In the meantime, we’d appreciate your involvement with the Sahana GIS work, so come join the community
Keep up the good work.
Nice work! keep it up, i think you should contribute this how to the Sahana WIKI also. So please join the community
Somehow i missed the point. Probably lost in translation
Anyway … nice blog to visit.
cheers, Amenorrhoea!!
#Amenorrhoea: sorry for my english
.