WCS wrapper for Mapserver
WMS,WFS and WCS is how it is possible to connected to a webGIS server and to download data:
WMS == Raster as an image
WFS == Vectorial information
WCS == Raster as a layer (original raster with values)
The request of WxF is normally done by a GET to the Mapserv program (is like a normal CGI-BIN for program execution), well I don't want Apache to run any program, so the solution is a wrapper PHP script, where the script catches the requests and uses them for a valid WCS reply.
The wrapper is very simple and there is a basic example on the mapserver home page, This is a wrapper with small modifications to work with WCS:
<?php
/*ows.php?service=WCS&version=1.0.0&Request=GetCapabilities*/
$request = ms_newowsrequestobj();
//$request->loadparams();
foreach ($_GET as $k=>$v) {
$request->setParameter($k, $v);
}
// forcing to version 1.0.0
$request->setParameter("VeRsIoN","1.0.0");
ms_ioinstallstdouttobuffer();
$oMap = ms_newMapobj("/usr/local/apache2/htdocs/secure/ms/data/calter.map");
$oMap->owsdispatch($request);
$contenttype = ms_iostripstdoutbuffercontenttype();
$buffer = ms_iogetstdoutbufferstring();
header('Content-type: application/xml');
echo $buffer;
ms_ioresethandlers();
?>
For start Mapserver only suports WCS version 1.0.0 so any request for higher versions has to be redirect:
$request->setParameter("VeRsIoN","1.0.0");
There seems to be a bug with $request->loadparams(); this produces an empy file reply from the server with no errors, so the solution it to get the parameters directely from the GET
foreach ($_GET as $k=>$v) {
$request->setParameter($k, $v);
}
if replacing $_GET for $_POST is should be possible to use POST to request the WCS, mapserver only accepts GET.
0 Comments:
Post a Comment
<< Home