GEOS Ruby Bindings via FFI
Requirements
-
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
Note that versions of JRuby prior to the as-of-yet (25 June 2011) unreleased version 1.6.3 have problems in their ffi implementation when dealing with AutoPointers that can lead to segfaults during garbage collection. Upcoming versions of JRuby should have the problem licked. For details, check out jira.codehaus.org/browse/JRUBY-5813.
Features
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
-
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
-
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
-
Geos::WktWriter#trim=
-
Geos::WktWriter#rounding_precision=
-
Geos::WktWriter#old_3d=
Geos::Utils
-
Geos::Utils.orientation_index
Thanks
-
Thanks to Daniel Azuma for the testing and JRuby help.
-
Christopher Meiklejohn for the bug reporting and PreparedGeometry fix.
-
Wayne Meissner for some help with some ffi issues.