Closed oleksii-leonov closed 9 years ago
Thanks for reporting this. I found this same exact issue when I put this in production, and I ended up splitting out the requires and only using ogr (that's all I really needed). I'm pretty sure this is a bug in the GDAL ruby bindings. This gem is basically just a copy of the SWIG code from GDAL with an extconf build script. I'd really like to get this fixed, but I haven't had time to dig into the SWIG code and actually see what's going on. Maybe it's overwriting a method or something?
Thanks! I will try to dig GDAL bindings and fix this bug (on this or next week).
Spend many hours today and make simple and working solution :) I 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.
So, now I write in Ruby Gdal::Ogr.ogr_get_driver_by_name
instead of Gdal::Ogr.get_driver_by_name
— and everything works fine, without any name conflicts.
But still interesting why problem with name conflicts was only on Linux. I suggest, that Linux shared objects (.so) and Mac OS bundles (.bundle) have other namespaces mechanisms ("Two-level Namespaces" in Mac OS resolves name conflicts of this type), but not sure.
Anyway, I make fork of gdal-ruby with this fix (https://github.com/aleksejleonov/gdal-ruby). Also will write to osgeo/gdal bug tracker with this issue — it will be better solution if they update gdal bindings.
This is great. Thanks for the info. In your opinion, is this fix good for a 0.0.6 on rubygems? If you think it's ready to go, you can create a pull request and I'll merge it in and get the fix up on rubygems. I'll leave that up to you, since you spent the time to look into the issue and know more about it :)
Also, have you looked at GDAL 1.9.2 that was recently released to see if there are any changes to the SWIG bindings? If there are any changes, we can get those in also.
Hi!
If I use only 'gdal-ruby/gdal' or 'gdal-ruby/ogr' — everything works fine. But when I require both — strange thing happen:
Gdal::Gdal.get_driver_by_name
return Gdal:: Ogr ::Driver object, not Gdal:: Gdal ::Driver.Example:
If I require only 'gdal-ruby/gdal' everything is Ok,
Gdal::Gdal.get_driver_by_name('GTiff')
return#<Gdal::Gdal::Driver:0x000000064b5b30>
. But, if I after that require 'gdal-ruby/ogr' thenGdal::Gdal.get_driver_by_name('GTiff')
return#<Gdal::Ogr::Driver:0x0000000509a3d0>
. ButGdal::Ogr.get_driver_by_name('GeoJson')
returnnil
.And this bug is only on Ubuntu Server 12.04 x64 (ruby 1.9.3-p194, GDAL 1.9.1). On Mac OS X (10.8, ruby 1.9.3-p194, GDAL 1.9.2) everything works fine and I can require both 'gdal-ruby/gdal' and 'gdal-ruby/ogr'.
Also tested this case with Python on same machine (Ubuntu Server 12.04 x64, ruby 1.9.3-p194, GDAL 1.9.1), but everything is fine — I can import both gdal and ogr and then GetDriverByName works correct.
Do you have any idea why this might happens?