3

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?

Dirk
  • 9,381
  • 17
  • 70
  • 98
  • Did you get this solved? I am encountering the same problem. – nathanvda Dec 22 '14 at 16:57
  • As far as I remember yes, but this was some time ago and I do not remember all the steps by heart. I think I have some notes how to do it somewhere at my workplace but I cannot access it before start of January. I will pick this up then. – Dirk Dec 24 '14 at 01:49
  • 1
    I would appreciate that. I have a workaround: use postgis to do coordinate transformation on windows, but it is an extra query I would like to avoid. – nathanvda Dec 24 '14 at 10:07
  • 1
    Happy new year! As far as I could find out, I could not make it work either back then. However, I think it worked on Windows when I used this gem: https://github.com/dark-panda/ffi-geos Have you already tried it? To use this ffi stuff after installing (via the gem manager), I did this: `#Create new factory for direct GEOS access` `my_factory = RGeo::Geos.factory(:native_interface => :ffi)` `puts RGeo::Geos.supported? # should return true` – Dirk Jan 05 '15 at 10:00

1 Answers1

3

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
PeteW
  • 681
  • 6
  • 9