ffi-geos is an implementation of the GEOS Ruby bindings in Ruby via FFI.
Pull request Compare This branch is 223 commits behind dark-panda:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


GEOS Ruby Bindings in FFI


  • the ffi extension for Ruby.

  • GEOS version 3.3.0 or greater. GEOS 3.2.2 and below will work to an extent, but some features and methods will be disabled or missing.

Ruby versions known to work:

  • Ruby MRI 1.8.7 and 1.9.2, x86_64, OSX 10.6.5+

  • Ruby MRI 1.8.7 and 1.9.2, i386, linux

  • Ruby MRI 1.8.7, x86_64, linux

  • JRuby 1.5 and 1.6 using JRE 1.6.0_22, x86_64, OSX 10.6.5+

  • JRuby 1.5 and 1.6 using JRE 1.6.0_18, i386, linux


ffi-geos supports all of the features found in the binary SWIG-based GEOS Ruby bindings along with the following enhancements and additions:

  • support for prepared geometries via Geos::Geometry#to_prepared.

  • an implementation of Geos::STRtree.

  • use of GEOS's re-entrant interface for thread-safety.

  • new options for controlling WKT output like trim and rounding precision.

  • many new methods on geometry types. See below for a list.

  • Geos::LineString, Geos::LinearRing, Geos::CoordinateSequence and Geos::GeometryCollection and its descendants are now enumerable.

  • The aforementioned enumerable classes also define some additional Array-like methods such as [] and slice.

  • Geos::WkbWriter and Geos::WktWriter have had their constructors extended to allow for settings via an options Hash.

  • Geos::WkbWriter#write, Geos::WkbWriter#write_hex and Geos::WktWriter#write have been enhanced to take options Hashes allowing you to set per-write settings.

  • Geos::BufferParams class that allows for more extensive Geos::Geometry#buffer options.

  • Geos::PreparedGeometry class and Geos::Geometry#to_prepared method to allow for prepared geometries and more efficient relationship testing.

New Methods and Additions (not exhaustive)


  • Geos.create_multi_point

  • Geos.create_multi_line_string

  • Geos.create_multi_polygon

  • Geos.create_geometry_collection

  • Geos.create_collection

  • Geos.create_empty_point

  • Geos.create_empty_polygon

  • Geos.create_empty_line_string

  • Geos.create_empty_multi_point

  • Geos.create_empty_multi_line_string

  • Geos.create_empty_multi_polygon

  • Geos.create_empty_geometry_collection


  • Geos::Geometry#num_coordinates

  • Geos::Geometry#union_cascaded. Geos::Geometry#union can also be called without a geometry argument to produce the same effect.

  • Geos::Geometry#extract_unique_points (aliased to Geos::Geometry#unique_points)

  • Geos::Geometry#valid_reason

  • Geos::Geometry#valid_detail

  • Geos::Geometry#project

  • Geos::Geometry#project_normalized

  • Geos::Geometry#interpolate

  • Geos::Geometry#interpolate_normalized

  • Geos::Geometry#start_point

  • Geos::Geometry#end_point

  • Geos::Geometry#hausdorff_distance

  • Geos::Geometry#snap

  • Geos::Geometry#shared_paths

  • Geos::Geometry#polygonize_full

  • Geos::Geometry#polygonize

  • Geos::Geometry#polygonize_cut_edges

  • Geos::Geometry#to_prepared

Geos::LineString and Geos::LinearRing

  • Geos::LineString#num_points

  • Geos::LineString#point_n

  • Geos::LineString#closed?


  • Geos::WktWriter#trim=

  • Geos::WktWriter#rounding_precision=

  • Geos::WktWriter#old_3d=


  • Geos::Utils.orientation_index