Open svilenkov opened 7 years ago
It could be that the the Gdal driver methods symbols somehow overwrite Ogr driver methods symbols since these 2 lines produce the same results
puts (0..119).map { |n| Gdal::Ogr.get_driver(n).get_name }.join(', ')
puts (0..Gdal::Gdal.get_driver_count-1).map { |n| Gdal::Gdal.get_driver(n).ShortName }.join(', ')
found a solution in an old issue: https://github.com/zhm/gdal-ruby/issues/2#issuecomment-9886376
Problem can be avoided if you recompile & install the gem by replacing GetDriver
with OGR_GetDriver
and GetDriverByName
with OGR_GetDriverByName
in the ogr.cpp.
@svilenkov We are experiencing the same issue, so thanks for posting this.
We worked around the problem by including a sample shapefile with our application, and then using it to get at the ESRI Shapefile driver, like so:
shapefile_path = File.join(File.dirname(__FILE__), 'shapefile')
shapfile_source = Gdal::Ogr.open(shapefile_path)
shapfile_source.get_driver
Is fixing this issue as simple as opening a pull request with the modification to ogr.cpp that you point out above, and then asking this gem's maintainer to accept the pull request? If so, it feels like we should go this route so that the issue is fixed for everyone.
Thanks, Denis
@denisahearn Nice, a clever workaround.
Is fixing this issue as simple as opening a pull request with the modification to ogr.cpp that you point out above, and then asking this gem's maintainer to accept the pull request? If so, it feels like we should go this route so that the issue is fixed for everyone.
That's true, although I haven't seen responses on this repo for quite some time. I've did the replacements and regenerated the SWIG bindings for the last 1.x gdal here: https://github.com/svilenkov/gdal-ruby/tree/gdal-1.11.5 Should probably make a pull-request out of this branch.
@svilenkov Thanks for posting the link to your forked repo.
It would be really nice if this were an actively maintained gem. It would also be nice it there was a version of this gem that worked with GDAL 2.x. (2.2.4 is the latest version as of this reply).
We rely on this gem in production, do you also? I would gladly help maintain this gem (or a fork of it), however I'm not sure what it would take to upgrade it to work with GDAL 2.x. I see that someone opened a pull request in this repo with changes to use GDAL 2.x back in May of 2016, but the gem's author didn't accept it (reasons are posted in the PR): https://github.com/zhm/gdal-ruby/pull/11.
@zhm Are you open to the idea of reviving this gem, and would you be willing to provide guidance on the best way to do that?
any plans for GDAL 3.x @svilenkov ?
I've run into a problem inside a debian Docker image when trying to use
ruby-gdal
. TheGdal::Ogr.get_driver_by_name('ESRI Shapefile')
returns nil on this linux platforms. According to the OGR docs the 'ESRI Shapefile' should be compiled by default. I have tested this also on a colleague's Ubuntu system and the same issues exists.This ruby snippet should list all registered OGR drivers:
output:
There is no sign of 'ESRI Shapefile'. Also, I find it strange that the 'GTiff' ends up in the OGR (Vector) driver namespace.
Gdal::Ogr.get_driver_count
gives a count of 61 available drivers. However If you set a manual loop end to 119, like in this examplewe get more drivers available than
Gdal::Ogr.get_driver_count
says there are:But still no trace of ESRI Shapefile
I've also tried calling
Gdal::Ogr.register_all
before the driver loop, but still no luck.Strangley on Mac OS X, when the same command is run from the ruby console the output is:
ESRI Shapefile is recognized, so there are no problems on OS X.
Here's some information about the Linux, ruby, gdal installation where this issue exists:
Dockerfile that is used for building ruby gdal image.
When using
ogrinfo --formats
the 'ESRI Shapefile' shows up as available.versions from the Gdal/Ogr command line
I've also tried building libgdal-dev from sources (gdal-1.10.1+dfsg) using
I've also tested getting driver information compiling a c++ that calls the same methods that are used in the ruby SWIG bindings inside the ruby-gdal gem.
In ogr.cpp (inside ruby-gdal gem) we have these methods definitions/wrappers
Then we have bindings for these defined methods
I've created test.cpp. It is suppose to do a similar output like the ruby snippet at the beggining of this text, but calling the same c++ methods as in the ruby bindings
Tested with the following command:
output:
So this leads to the conclusion that there is something wrong with
gdal-ruby
bindings that leads to many OGR drivers not to be available. I don't understand why does this difference exist and why do identical c++ methods return different drivers?I've created a github repository with the Dockerfile, testing examples and instructions on what to run to see the driver outputs from ruby vs cpp https://github.com/svilenkov/ruby-gdal-driver-issue/