-
-
Notifications
You must be signed in to change notification settings - Fork 374
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP MapScript WMS failing on GetMap requests #5798
Comments
Hi @jwgda... This should be reported via the mailing lists where many more eyes can take a look at it. Lot's of PHP/MapScript users out there but I'm not one of them. --Steve |
Seems like I'm not the only one |
@jwgda, what version of everything are you running? I'll reopen this and close the old ticket... I would still take the question to the user list to see if others are experiencing the same issue. I thought this was a pretty common use case. --Steve |
Thanks Steve. I'm using the MS4W 4.0 package build which contains: MapServer 7.4.0-dev, GDAL 2.4.0, Apache 2.4.38, PHP 7.2.16, MapCache 1.7dev. I also posted to the MS4W User mailing list a couple weeks ago, but no response yet (https://lists.ms4w.com/pipermail/ms4w-users/2019-April/thread.html). If there's another list I can post to, let me know. |
So this is with the Swig-based version of PHP MapScript. I'll try the same script in Perl and see what happens. You might want to try mapserver-users as well. |
Correct. Thank you. |
Here is a working SWIG Python MapScript GetMap request: extent = map.extent
print(extent)
bbox = "BBOX={},{},{},{}".format(extent.minx, extent.miny, extent.maxx, extent.maxy)
querystring = "SERVICE=WMS&REQUEST=GetMap&VERSION=1.3.0&LAYERS=lakespy2&CRS=EPSG:26915&FORMAT=image/png&WIDTH=400&HEIGHT=400&{}".format(bbox)
ows_req = mapscript.OWSRequest()
ows_req.loadParamsFromURL(querystring)
success = map.OWSDispatch(ows_req)
assert success == mapscript.MS_SUCCESS
# clear the HTTP headers or we will have an invalid image
headers = mapscript.msIO_getAndStripStdoutBufferMimeHeaders()
result = mapscript.msIO_getStdoutBufferBytes()
output_file = "wms.png"
with open(output_file, "wb") as f:
f.write(result) |
This is the piece I'm missing -- could it be the reason? However, there is no such function (msIO_getAndStripStdoutBufferMimeHeaders) defined in the PHP SWIG Mapscript library (/ms4w/apps/phpmapscriptng-swig/include/mapscript.php) -- code attached. |
This function was made available in the 7-4 beta release as part of the Perl updates: https://github.com/mapserver/mapserver/pull/5778/files There is a new 7.4 release candidate out very soon, so maybe try with this? |
I ran into the same issue porting some old PHP Mapscript code to PHP7 and SWIG Mapscript. The problem here is apparently with msIO_getStdoutBufferBytes(), as there is no obvious way to get the content of this buffer in SWIGH PHP Mapscript. According to the SWIG Mapscript documentation:
Calling $res=msIO_getStdoutBufferBytes() in PHP outputs nothing, and returns a resource handle to the buffer. (See also http://osgeo-org.1560.x6.nabble.com/PHP-Mapscript-Swig-td5404624.html). Contrast this with the old, non-SWIG PHP Mapscript, where calling ms_iogetStdoutBufferBytes() would write content of the current buffer to stdout:
|
MS4W will now be updated with this fix, for Windows users. |
PHP Mapscript WMS GetMap requests are not returning any result.
WMS requests going through CGI requests with a static mapfile are successful, e.g.
http://localhost:8080/cgi-bin/mapserv.exe?map=mymap.map&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=TRUE&LAYERS=L_01&SRS=EPSG%3A3857&CRS=EPSG%3A3857&STYLES=&WIDTH=1920&HEIGHT=1068&BBOX=-19200000%2C-10680000%2C19200000%2C10680000
However, loading that same mapfile in PHP Mapscript with exact same parameters returns no result.
No errors are written in the MS_ERRORFILE, and owsDispatch command returns 0 (MS_SUCCESS).
Example of code that returns no result.
$oMap = new mapObj("mymap.map");
$request = new OWSRequest();
$request->setParameter('service','WMS');
$request->setParameter('SLD_VERSION','1.1.0');
msIO_installStdoutToBuffer();
$oMap->owsDispatch($request);
$contenttype = msIO_stripStdoutBufferContentType();
header('Content-type: image/png');
msIO_getStdoutBufferBytes();
msIO_resetHandlers();
The text was updated successfully, but these errors were encountered: