wiki:WMSWrapper4x

WMS Wrapper example (MS4W 4.x)

SWIG MapScript [ This is now working and is resolved :) ]

<?php

include("../includes/phpmapscriptng-swig/mapscript.php");
$oMap= new mapObj($mymapfile);

## Ready stdout for data capture
msIO_installStdoutToBuffer();

## Create OWS Request object
$request = new OWSRequest();

## Get Request
foreach ($_GET as $k=>$v) {
    $request->setParameter($k, $v);
}

## Dispatch request
$oMap->OWSDispatch($request);

unset($oMap);

$contenttype = strtolower(msIO_stripStdoutBufferContentType());

## Capabilities Request
if ($contenttype == "application/vnd.ogc.wms_xml; charset=utf-8"){
    header('Content-type: application/xml; charset=utf-8');
    echo msIO_getStdoutBufferString();
}

## GetMap jpeg
else if ($contenttype == 'image/jpeg'){
    header('Content-type: image/jpeg');
    echo msIO_getStdoutBufferBytes();
}


## Reset handler and cleaup added
msIO_resetHandlers();
msCleanup();

?>

Old MapScript

<?php

$oMap= ms_newMapObj($mymapfile);

ms_ioinstallstdouttobuffer();

$request = ms_newowsrequestobj();

//Get Request
foreach ($_GET as $k=>$v) {
    $request->setParameter($k, $v);
}

$oMap->owsdispatch($request);
$oMap->free();
unset($oMap);

$contenttype = strtolower(ms_iostripstdoutbuffercontenttype());

//Capabilities Request
if ($contenttype == "application/vnd.ogc.wms_xml; charset=utf-8"){
    header('Content-type: application/xml; charset=utf-8');
    echo ms_iogetstdoutbufferstring();
}

//getMap jpeg
else if ($contenttype == 'image/jpeg'){
    header('Content-type: image/jpeg');
    echo ms_iogetStdoutBufferBytes();
} 

?>
Last modified 3 years ago Last modified on 2021-12-22T12:11:27-04:00
Note: See TracWiki for help on using the wiki.