forked from zhm/gdal-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
GDAL Ruby SWIG bindings
Oleksii Leonov edited this page Oct 24, 2017
·
2 revisions
- SWIG docs for Ruby — http://www.swig.org/Doc3.0/SWIGDocumentation.html#Ruby
- About renaming — http://qpid.2158936.n2.nabble.com/Swig-renaming-of-C-classes-for-Ruby-bindings-td7399660.html
- GDAL sources — https://trac.osgeo.org/gdal/wiki/DownloadSource
wget http://download.osgeo.org/gdal/2.2.2/gdal-2.2.2.tar.gz
tar -zxvf gdal-2.2.2.tar.gz && cd gdal-2.2.2
cd swig/ruby
swig -Wall -I../include -I../include/ruby -I../include/ruby/docs -I../.. -c++ -ruby -autorename -prefix "Gdal::" -o gdal.cpp ../include/gdal.i
swig -Wall -I../include -I../include/ruby -I../include/ruby/docs -I../.. -ruby -autorename -prefix "Gdal::" -o gdalconst.c ../include/gdalconst.i
swig -Wall -I../include -I../include/ruby -I../include/ruby/docs -I../.. -c++ -ruby -autorename -prefix "Gdal::" -o osr.cpp ../include/osr.i
swig -Wall -I../include -I../include/ruby -I../include/ruby/docs -I../.. -c++ -ruby -autorename -prefix "Gdal::" -o ogr.cpp ../include/ogr.i
This actions required only when you need to use gdal
and ogr
methods in same code.
There is old issue with names when require
gdal-ruby/gdal
and gdal-ruby/ogr
same time: https://github.com/zhm/gdal-ruby/issues/2.
Workaround — rename OGR GetDriverByName
and GetDriver
(in ogr.i from gdal source gdal/swig/include) to OGR_GetDriverByName
and OGR_GetDriver
. After that rebuild wrappers with SWIG, and get functions ogr_get_driver_by_name
and ogr_get_driver
for Ruby.
Now use Gdal::Ogr.ogr_get_driver_by_name
instead of Gdal::Ogr.get_driver_by_name
in Ruby.