| 1 | - source: https://lists.ms4w.com/pipermail/ms4w-users/2019-May/000343.html |
| 2 | - note: likely solution is included in next MapServer release: |
| 3 | |
| 4 | ---- |
| 5 | |
| 6 | == SWIG MapScript (currently fails) == |
| 7 | {{{ |
| 8 | #!php |
| 9 | include("../includes/phpmapscriptng-swig/mapscript.php"); |
| 10 | $oMap= new mapObj($mymapfile); |
| 11 | |
| 12 | msIO_installStdoutToBuffer(); |
| 13 | |
| 14 | $request = new OWSRequest(); |
| 15 | |
| 16 | //Get Request |
| 17 | foreach ($_GET as $k=>$v) { |
| 18 | $request->setParameter($k, $v); |
| 19 | } |
| 20 | |
| 21 | $oMap->OWSDispatch($request); |
| 22 | |
| 23 | unset($oMap); |
| 24 | |
| 25 | $contenttype = strtolower(msIO_stripStdoutBufferContentType()); |
| 26 | |
| 27 | //Capabilities Request |
| 28 | if ($contenttype == "application/vnd.ogc.wms_xml; charset=utf-8"){ |
| 29 | header('Content-type: application/xml; charset=utf-8'); |
| 30 | echo msIO_getStdoutBufferString(); |
| 31 | } |
| 32 | |
| 33 | //getMap jpeg |
| 34 | else if ($contenttype == 'image/jpeg'){ |
| 35 | header('Content-type: image/jpeg'); |
| 36 | echo msIO_getStdoutBufferBytes(); |
| 37 | } |
| 38 | }}} |
| 39 | |
| 40 | == Old MapScript == |
| 41 | {{{ |
| 42 | #!php |
| 43 | $oMap= ms_newMapObj($mymapfile); |
| 44 | |
| 45 | ms_ioinstallstdouttobuffer(); |
| 46 | |
| 47 | $request = ms_newowsrequestobj(); |
| 48 | |
| 49 | //Get Request |
| 50 | foreach ($_GET as $k=>$v) { |
| 51 | $request->setParameter($k, $v); |
| 52 | } |
| 53 | |
| 54 | $oMap->owsdispatch($request); |
| 55 | $oMap->free(); |
| 56 | unset($oMap); |
| 57 | |
| 58 | $contenttype = strtolower(ms_iostripstdoutbuffercontenttype()); |
| 59 | |
| 60 | //Capabilities Request |
| 61 | if ($contenttype == "application/vnd.ogc.wms_xml; charset=utf-8"){ |
| 62 | header('Content-type: application/xml; charset=utf-8'); |
| 63 | echo ms_iogetstdoutbufferstring(); |
| 64 | } |
| 65 | |
| 66 | //getMap jpeg |
| 67 | else if ($contenttype == 'image/jpeg'){ |
| 68 | header('Content-type: image/jpeg'); |
| 69 | echo ms_iogetStdoutBufferBytes(); |
| 70 | } |
| 71 | }}} |