RGeo on Ruby under Windows: How to enable GEOS support?

≡放荡痞女 提交于 2019-12-22 11:28:37

问题


I'm trying to do some spatial operations in Ruby with the RGeo gem. Unfortunately, a lot of operations require the GEOS library and I can't find any documentation showing how to integrate this in Windows (I am using Windows 7 64bit).

I tried downloading and installing the Windows binaries of GEOS from http://trac.osgeo.org/osgeo4w/ and reinstalling the RGeo gem via gem install rgeo -- --with-geos-dir="C:\OSGeo4W64\bin (<< in this directory there is a file geos_c.dll).

Still, using RGeo::Geos.supported? returns false.

Does anybody know how to solve this?


回答1:


For anyone else looking to do this - here are some tips as to how I got it working.

  • install GEOS Windows binaries by following the link from http://trac.osgeo.org/geos/ (I have Ruby 32 bit version, so I went for the 32 bit version)
  • you should now be able to find a file geos_c.dll in C:\OSGeo4W\bin
  • set a Windows environment variable ENV['GEOS_LIBRARY_PATH'] to be C:\OSGeo4W\bin
  • check at this point to make sure that ENV variable is there - maybe restart your PC!
  • in your Gemfile, add gem 'ffi-geos' and gem 'rgeo' and bundle install
  • in your Ruby file, remember to require 'ffi-geos' and require 'rgeo' (in that order)
  • use factory = RGeo::Geos.factory(:native_interface => :ffi) - not RGeo::Cartesian.factory
  • check RGeo::Geos.supported? as Dirk said


来源:https://stackoverflow.com/questions/22297117/rgeo-on-ruby-under-windows-how-to-enable-geos-support

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!