Skip to content

Commit

Permalink
Experimental support for ffi-geos
Browse files Browse the repository at this point in the history
  • Loading branch information
dazuma committed May 18, 2011
1 parent ca74f14 commit 871c252
Show file tree
Hide file tree
Showing 33 changed files with 2,060 additions and 45 deletions.
9 changes: 9 additions & 0 deletions History.rdoc
@@ -1,3 +1,12 @@
=== 0.3.0 / 2011-05-18

RailsConf Edition

* GEOS implementation now supports native GEOS integration via ffi-geos in addition to RGeo's built-in C integration. This should enable us to provide the GEOS implementation on JRuby. This is experimental at the moment since ffi-geos is still in early beta.
* Taking the boundary of a GEOS GeometryCollection now returns nil. It used to return an empty GeometryCollection, regardless of the contents of the original collection. GeometryCollection subclasses like MultiPoint, however, do have proper boundaries.
* Renamed the lenient_multi_polygon_assertions GEOS factory parameter to uses_lenient_multi_polygon_assertions. The older name will continue to work.
* The GEOS buffer_resolution and uses_lenient_multi_polygon_assertions options are now exposed via properties.

=== 0.2.9 / 2011-04-25

* INCOMPATIBLE CHANGE: mutator methods for the configurations of the WKRep parsers and generators have been removed. Create a new parser/generator if you need to change behavior.
Expand Down
7 changes: 2 additions & 5 deletions ext/geos_c_impl/geometry.c
Expand Up @@ -191,12 +191,9 @@ static VALUE method_geometry_boundary(VALUE self)
if (self_geom) {
GEOSContextHandle_t geos_context = self_data->geos_context;
GEOSGeometry* boundary = GEOSBoundary_r(geos_context, self_geom);
// GEOS returns NULL for the boundary of an empty collection.
// Replace that with an empty collection.
if (!boundary) {
boundary = GEOSGeom_createCollection_r(geos_context, GEOS_GEOMETRYCOLLECTION, NULL, 0);
if (boundary) {
result = rgeo_wrap_geos_geometry(self_data->factory, boundary, Qnil);
}
result = rgeo_wrap_geos_geometry(self_data->factory, boundary, Qnil);
}
return result;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/rgeo/geographic/projected_feature_methods.rb
Expand Up @@ -71,7 +71,8 @@ def is_simple?


def boundary
factory.unproject(projection.boundary)
boundary_ = projection.boundary
boundary_ ? factory.unproject(boundary_) : nil
end


Expand Down
16 changes: 16 additions & 0 deletions lib/rgeo/geos.rb
Expand Up @@ -68,5 +68,21 @@ module Geos
require 'rgeo/geos/geos_c_impl'
rescue ::LoadError; end
require 'rgeo/geos/impl_additions'
require 'rgeo/geos/ffi_factory'
require 'rgeo/geos/ffi_classes'
require 'rgeo/geos/zm_factory'
require 'rgeo/geos/zm_impl'

# Determine native interface support.
begin
require 'ffi-geos'
::RGeo::Geos::FFI_SUPPORTED = true
rescue ::LoadError
::RGeo::Geos::FFI_SUPPORTED = false
end
::RGeo::Geos::CAPI_SUPPORTED = ::RGeo::Geos::Factory.respond_to?(:_create) ? true : false
if ::RGeo::Geos::CAPI_SUPPORTED
::RGeo::Geos.preferred_native_interface = :capi
elsif ::RGeo::Geos::FFI_SUPPORTED
::RGeo::Geos.preferred_native_interface = :ffi
end
6 changes: 5 additions & 1 deletion lib/rgeo/geos/factory.rb
Expand Up @@ -61,7 +61,7 @@ def create(opts_={})

# Get flags to pass to the C extension
flags_ = 0
flags_ |= 1 if opts_[:lenient_multi_polygon_assertions]
flags_ |= 1 if opts_[:lenient_multi_polygon_assertions] || opts_[:uses_lenient_multi_polygon_assertions]
flags_ |= 2 if opts_[:has_z_coordinate]
flags_ |= 4 if opts_[:has_m_coordinate]
if flags_ & 6 == 6
Expand Down Expand Up @@ -200,6 +200,10 @@ def property(name_)
_flags & 0x4 != 0
when :is_cartesian
true
when :uses_lenient_multi_polygon_assertions
_flags & 0x1 != 0
when :buffer_resolution
_buffer_resolution
else
nil
end
Expand Down

0 comments on commit 871c252

Please sign in to comment.