If I understand the Rgeo doc & code correctly, there's CAPIFactory which is supposed to link to GEOS and there is FFIFactory using ffi-geos gem which links to GEOS using FFI.
Both of these seem to be achieving the same objective. Why does Rgeo implement 2 separate factories for the same thing?
The
CAPIFactorycan be used for versions of Ruby that support C Extensions. The most common version of Ruby (MRI) is written in C and thus supports C Extensions, but other kinds (JRuby for example) are written in Java or other languages that don't support C Extensions. In that case, they can use theFFIFactoryto interface with GEOS, but it is not as fast as the nativeCAPIFactory.Basically, the
FFIFactorygives the ability to use GEOS to all versions of Ruby at the cost of some performance.