Re: [mapserver-users] MapServer 6.4.1 OGR output error
To me it seems the WFS code uses msReturnTemplateQuery() from maptemplate.c but this is not exported to (PHP-)MapScript... I would guess that the only way to get OGR output would be to fake a OWS-Request: ?php $map = ms_newMapObj(./toto.map); $req = new OWSRequestObj(); $args = Array(service = WFS, request = GetFeature, version = 1.1.0, typename = Bati); foreach($args as $param = $value) $req-setParameter($param, $value); $req-setParameter(outputformat, $_REQUEST[type_fichier]); // $map-loadOWSParameters($req); $map-owsDispatch($req); ? Requires enabling the request type and the output format: WEB METADATA Ows_enable_request * Wfs_getfeature_formatlist dxf midmif shapezip csv kmz END END HTH -Ursprüngliche Nachricht- Von: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users- boun...@lists.osgeo.org] Im Auftrag von Bruno D Gesendet: Freitag, 20. Februar 2015 16:27 An: mapserver-users@lists.osgeo.org Betreff: Re: [mapserver-users] MapServer 6.4.1 OGR output error Hi Andreas, Thanks for your answer. I tried using savequeryasgml(), but it creates a blank gml file that only contains the following text : /?xml version=1.0 encoding=ISO-8859-1? msGMLOutput xmlns:gml=http://www.opengis.net/gml; xmlns:xlink=http://www.w3.org/1999/xlink; xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance; /msGMLOutput/ I'll look into that, but as you stated there is almost no documentation... Could someone who succeeded in outputting a DXF/SHP/... file through OGR post a working example ? Thanks ! Bruno -- View this message in context: http://osgeo- org.1560.x6.nabble.com/MapServer-6-4-1-OGR-output-error- tp5172655p5188948.html Sent from the Mapserver - User mailing list archive at Nabble.com. ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] MapServer 6.4.1 OGR output error
Thank you so much Andreas, your solution works perfectly ! I would never have thought of it by myself. Now all I have to do is understand why the generated zip files seem invalid (I can see their content with 7zip, but I can't extract them)... Thanks everyone for your help ! -- View this message in context: http://osgeo-org.1560.x6.nabble.com/MapServer-6-4-1-OGR-output-error-tp5172655p5189444.html Sent from the Mapserver - User mailing list archive at Nabble.com. ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] MapServer 6.4.1 OGR output error
You are too quick to answer ! I was suspecting the header problem, but I was still looking for the solution. Once again what you suggested works perfectly ! Thanks a lot for your help ! -- View this message in context: http://osgeo-org.1560.x6.nabble.com/MapServer-6-4-1-OGR-output-error-tp5172655p5189489.html Sent from the Mapserver - User mailing list archive at Nabble.com. ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] MapServer 6.4.1 OGR output error
Maybe you tried to use the result directly? The owsDispatch() method creates content _plus_ headers. To get the plain content you need to write the output into a buffer, strip off the headers and fetch the contents of the buffer: ms_ioinstallstdouttobuffer(); $map-owsDispatch($req); ms_iostripstdoutbuffercontentheaders(); $result = ms_iogetstdoutbufferstring(); print_r($result); To correct my self: the Wfs_getfeature_formatlist is a comma separated list. -Ursprüngliche Nachricht- Von: mapserver-users-boun...@lists.osgeo.org [mailto:mapserver-users- boun...@lists.osgeo.org] Im Auftrag von Bruno D Gesendet: Montag, 23. Februar 2015 15:11 An: mapserver-users@lists.osgeo.org Betreff: Re: [mapserver-users] MapServer 6.4.1 OGR output error Thank you so much Andreas, your solution works perfectly ! I would never have thought of it by myself. Now all I have to do is understand why the generated zip files seem invalid (I can see their content with 7zip, but I can't extract them)... Thanks everyone for your help ! -- View this message in context: http://osgeo- org.1560.x6.nabble.com/MapServer-6-4-1-OGR-output-error- tp5172655p5189444.html Sent from the Mapserver - User mailing list archive at Nabble.com. ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] MapServer 6.4.1 OGR output error
You can't use OGR output formats that way. Calling msPrepareImage() on them triggers a NULL pointer dereference (fixed in https://github.com/mapserver/mapserver/pull/5069). So using $image = $map-draw() $image_url = $image-saveWebImage() is definitely the wrong way. The MapServer code hints to use msGMLWriteQuery() for that which seems to be exported as $map-savequeryasgml(string filename, string namespace) Documentation is rare on that... Am I the only one having problems outputting OGR files ? Does anybody know what I could be doing wrong ? ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] MapServer 6.4.1 OGR output error
Lars Fricke Dear Bruno, sorry we did not get back to you. I'm not really sure what your problem could be. Could you: 1) Tell us what you tried already (you said it was a lot) so we do not have to think in a direction you already ruled out. 2) Did you look into the logfile of the web server (not the map server, that you posted)? Maybe there is something there. 3) Did you check on the options with which your MapServer was compiled? You can use mapserv -v (on Linux at least). Hope this gets you further. Best Lars Am 20.02.2015 um 10:57 schrieb Bruno D: Hi all, I never got any answer to my problem, and it still isn't solved. Am I the only one having problems outputting OGR files ? Does anybody know what I could be doing wrong ? Thanks, Bruno -- View this message in context: http://osgeo-org.1560.x6.nabble.com/MapServer-6-4-1-OGR-output-error-tp5172655p5188833.html Sent from the Mapserver - User mailing list archive at Nabble.com. ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] MapServer 6.4.1 OGR output error
Hi all, I never got any answer to my problem, and it still isn't solved. Am I the only one having problems outputting OGR files ? Does anybody know what I could be doing wrong ? Thanks, Bruno -- View this message in context: http://osgeo-org.1560.x6.nabble.com/MapServer-6-4-1-OGR-output-error-tp5172655p5188833.html Sent from the Mapserver - User mailing list archive at Nabble.com. ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] MapServer 6.4.1 OGR output error
Dear Lars, Thanks for your quick answer ! I tried a lot of things, amongst which : * Compiling and installing MapServer 6.4.1 with different parameters concerning GDal and LibGD * Installing different GDal versions * Selecting outputformat in the mapfile or in the PHP script * Many other things I have since then forgotten... My web server shows no error, the only errors I get are the MapServer ones I posted. mapserv -v gives the following result : MapServer version 6.4.1 OUTPUT=PNG OUTPUT=JPEG OUTPUT=KML SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=CAIRO SUPPORTS=ICONV SUPPORTS=FRIBIDI SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=FASTCGI SUPPORTS=GEOS INPUT=JPEG INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE Thanks for your help, I'm very pleased with Mapserver and the OGR output is the last thing that does not work. Best Bruno -- View this message in context: http://osgeo-org.1560.x6.nabble.com/MapServer-6-4-1-OGR-output-error-tp5172655p5188947.html Sent from the Mapserver - User mailing list archive at Nabble.com. ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] MapServer 6.4.1 OGR output error
Hi all, Sorry I forgot to add the debug output : /[Thu Nov 13 09:26:55 2014].276919 msDrawMap(): rendering using outputformat named png (AGG/PNG). [Thu Nov 13 09:26:55 2014].276942 msDrawMap(): WMS/WFS set-up and query, 0.000s [Thu Nov 13 09:26:55 2014].611233 msDrawMap(): Layer 0 (Bati), 0.334s [Thu Nov 13 09:26:55 2014].611246 msDrawMap(): Drawing Label Cache, 0.000s [Thu Nov 13 09:26:55 2014].611250 msDrawMap() total time: 0.336s [Thu Nov 13 09:26:55 2014].624686 msFreeMap(): freeing map at 0xc4a480. [Thu Nov 13 09:27:14 2014].559160 msPrepareImage(): GD library error. Unable to initialize image. [Thu Nov 13 09:27:14 2014].559179 msDrawMap(): Image handling error. Unable to initialize image. [Thu Nov 13 09:27:14 2014].560997 msFreeMap(): freeing map at 0xc4a4c0./ There is a GD library error, I checked and GD (libGD v2.0.34) seems to be installed correctly on my server. I thought MapServer no longer used GD unless the installation parameters stated otherwise, am I wrong ? Thanks -- View this message in context: http://osgeo-org.1560.x6.nabble.com/MapServer-6-4-1-OGR-output-error-tp5172655p5172731.html Sent from the Mapserver - User mailing list archive at Nabble.com. ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users
[mapserver-users] MapServer 6.4.1 OGR output error
Hi everyone, I'm using MapServer on a CentOS 6 server, everything works fine except for the OGR output. When I try to select an outputformat that uses OGR, I always get the following errors (and nothing more, making debugging really difficult) : *msDrawMap() : Unable to initialize image. msPrepareImage() : Unable to initialize image.* I tried a lot of things but I still haven't found the source of this problem, does anyone have any idea ? Thanks ! Server configuration : *MapServer 6.4.1 GDal 1.9.2 (also tried with GDal 1.8.1)* Example of a mapfile I'm trying to output (PNG and KMZ work fine, the other formats don't) : /MAP NAME TOTO SIZE 1000 600 STATUS ON SYMBOLSET ./symbols.txt EXTENT -10 40 9 51 UNITS DD SHAPEPATH ./shapefiles CONFIG MS_ERRORFILE ./erreurs_mapserver.txt CONFIG CPL_DEBUG ON CONFIG PROJ_DEBUG ON DEBUG 5 PROJECTION init=epsg:4326 END WEB IMAGEPATH ./output/ IMAGEURL ./output/ END # WEB OUTPUTFORMAT NAME png DRIVER AGG/PNG MIMETYPE image/png IMAGEMODE RGB EXTENSION png END OUTPUTFORMAT NAME kmz DRIVER KMZ MIMETYPE application/vnd.google-earth.kmz IMAGEMODE RGB EXTENSION kmz FORMATOPTION maxfeaturestodraw=10 END OUTPUTFORMAT NAME CSV DRIVER OGR/CSV MIMETYPE text/csv FORMATOPTION LCO:GEOMETRY=AS_WKT FORMATOPTION STORAGE=filesystem FORMATOPTION FORM=simple FORMATOPTION FILENAME=result.csv END OUTPUTFORMAT NAME SHAPEZIP DRIVER OGR/ESRI Shapefile FORMATOPTION STORAGE=memory FORMATOPTION FORM=zip FORMATOPTION FILENAME=result.zip END OUTPUTFORMAT NAME MIDMIF DRIVER OGR/MapInfo File FORMATOPTION STORAGE=filesystem FORMATOPTION FORM=multipart FORMATOPTION DSCO:FORMAT=MIF FORMATOPTION FILENAME=result.mif END OUTPUTFORMAT NAME DXF DRIVER OGR/DXF FORMATOPTION STORAGE=filesystem FORMATOPTION FORM=zip FORMATOPTION FILENAME=result.csv END LAYER DATA Bati METADATA ows_title Bati END # METADATA NAME Bati STATUS ON TILEITEM location TYPE POLYGON UNITS METERS CLASS NAME Bati STYLE ANGLE 0 COLOR 103 132 169 OFFSET 0 0 OUTLINECOLOR 0 0 0 WIDTH 0.91 END # STYLE END # CLASS PROJECTION init=epsg:27561 END END # LAYER END # MAP/ And the corresponding PHP file : /$map = ms_newMapObj(./toto.map); if($_REQUEST[type_fichier] == kmz) { $map-selectOutputFormat(kmz); } else if($_REQUEST[type_fichier] == shp) { $map-selectOutputFormat(SHAPEZIP); } else if($_REQUEST[type_fichier] == dxf) { $map-selectOutputFormat(DXF); } else if($_REQUEST[type_fichier] == midmif) { $map-selectOutputFormat(MIDMIF); } else if($_REQUEST[type_fichier] == csv) { $map-selectOutputFormat(CSV); } try { $image = $map-draw(); if($image != NULL) { $image_url = $image-saveWebImage(); echo okbr. $image_url; } else { echo pasokbr; $error = ms_GetErrorObj(); while($error $error-code != MS_NOERR) { echo $error-routine. : .$error-message.br; $error = $error-next(); } } } catch(Exception $e) { echo pasokbr; echo $e-getMessage().br; $error = ms_GetErrorObj(); while($error $error-code != MS_NOERR) { echo $error-routine. : .$error-message.br; $error = $error-next(); } }/ -- View this message in context: http://osgeo-org.1560.x6.nabble.com/MapServer-6-4-1-OGR-output-error-tp5172655.html Sent from the Mapserver - User mailing list archive at Nabble.com. ___ mapserver-users mailing list mapserver-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapserver-users