Fixes to PHP swig bindings
|Reported by:||mgleahy||Owned by:||hobu|
|Component:||SWIG (all bindings)||Version:||svn-trunk|
I've attached a patch that will allow partial functionality of the PHP swig bindings, which I had described in the gdal-dev mailing list.
Essentially, I updated the swig/php/GNUmakefile to ensure libraries are linked and that all modules were built. I also updated some of the PHP typemaps to account for a missing CSL typemap, and corrected the OGRErr typemaps to only return an error for non-zero responses. That was the first step that got the php_osr.so module working (without detailed tests that is).
I also found some function name conflicts when the gdal/ogr libraries were loaded into PHP, so I've added some %rename statements to deal with those. However, the php_gdal.so and php_ogr.so bindings still have issues. For example, CreateGeometryFromJson works with ogr, but CreateGeometryFromWkt segfaults with what appears to be a null pointer exception. php_gdal.so segfaults immediately when the module is loaded. (see the attached valgrind outputs).
Also, as I had noted in the mailing list, swig frequently inserts zend_error_noreturn into the *_wrap.cpp files, while PHP no longer provides this function. I've manually substituted zend_error so that errors can be raised within the PHP environment successfully. (I realize this is a swig-specific issue).
I've also attached a sample PHP script that demonstrates the OSR/OGR functionality, as well as raises an error with the OGR wkt geometry constructor.
I used the svn trunk to generate the attached patch, but as far as I can tell it will still work against a clean copy of 1.8.0.