Changes between Initial Version and Version 1 of WMSWrapper4x


Ignore:
Timestamp:
2021-12-22T12:11:02-04:00 (2 years ago)
Author:
Jeff McKenna
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WMSWrapper4x

    v1 v1  
     1= WMS Wrapper example =
     2
     3 - source: https://lists.ms4w.com/pipermail/ms4w-users/2019-May/000343.html
     4 - note: likely solution is included in next !MapServer release ([[https://github.com/mapserver/mapserver/pull/5778/files#diff-127c91f36292dd4e75e861fb07c29f1f|diff]])
     5
     6== SWIG !MapScript [ This is now working and is resolved :) ] ==
     7{{{
     8#!php
     9<?php
     10
     11include("../includes/phpmapscriptng-swig/mapscript.php");
     12$oMap= new mapObj($mymapfile);
     13
     14## Ready stdout for data capture
     15msIO_installStdoutToBuffer();
     16
     17## Create OWS Request object
     18$request = new OWSRequest();
     19
     20## Get Request
     21foreach ($_GET as $k=>$v) {
     22    $request->setParameter($k, $v);
     23}
     24
     25## Dispatch request
     26$oMap->OWSDispatch($request);
     27
     28unset($oMap);
     29
     30$contenttype = strtolower(msIO_stripStdoutBufferContentType());
     31
     32## Capabilities Request
     33if ($contenttype == "application/vnd.ogc.wms_xml; charset=utf-8"){
     34    header('Content-type: application/xml; charset=utf-8');
     35    echo msIO_getStdoutBufferString();
     36}
     37
     38## GetMap jpeg
     39else if ($contenttype == 'image/jpeg'){
     40    header('Content-type: image/jpeg');
     41    echo msIO_getStdoutBufferBytes();
     42}
     43
     44
     45## Reset handler and cleaup added
     46msIO_resetHandlers();
     47msCleanup();
     48
     49?>
     50}}}
     51
     52== Old !MapScript ==
     53
     54{{{
     55#!php
     56<?php
     57
     58$oMap= ms_newMapObj($mymapfile);
     59
     60ms_ioinstallstdouttobuffer();
     61
     62$request = ms_newowsrequestobj();
     63
     64//Get Request
     65foreach ($_GET as $k=>$v) {
     66    $request->setParameter($k, $v);
     67}
     68
     69$oMap->owsdispatch($request);
     70$oMap->free();
     71unset($oMap);
     72
     73$contenttype = strtolower(ms_iostripstdoutbuffercontenttype());
     74
     75//Capabilities Request
     76if ($contenttype == "application/vnd.ogc.wms_xml; charset=utf-8"){
     77    header('Content-type: application/xml; charset=utf-8');
     78    echo ms_iogetstdoutbufferstring();
     79}
     80
     81//getMap jpeg
     82else if ($contenttype == 'image/jpeg'){
     83    header('Content-type: image/jpeg');
     84    echo ms_iogetStdoutBufferBytes();
     85}
     86
     87?>
     88}}}