RGeo: No success in checking for geometric overlap

102 views
Skip to first unread message

Daniel Angell

unread,
Nov 12, 2015, 5:42:49 PM11/12/15
to RGeo-Users
I'm currently using RGeo with RGeoJSON to load a GeoJSON file containing a list of polygonal areas in a city. However, when I try to check if one of those polygons contains a point I'm told that the object does not have the include? method (even though the method shows up in .methods).

wards = RGeo::GeoJSON.decode(File.read('./db/json/Political_Wards.geojson'), :json_parser => :json)
point
= RGeo::GeoJSON.decode('{"type":"Point","coordinates":[' + lat + ',' + lon + ']}', json_parser: :json)

wards
.first.geometry.class
=> RGeo::Cartesian::PolygonImpl

wards
.first.methods - BasicObject.methods
=> [:geometry, :feature_id, :properties, :property, :[], :keys]

wards
.first.geometry.methods - BasicObject.methods
=> [:srid, :envelope, :exterior_ring, :num_interior_rings, :interior_ring_n, :interior_rings, :dimension, :geometry_type, :is_empty?, :boundary, :rep_equals?, :_copy_state_from, :_validate_geometry, :_set_factory, :factory, :as_text, :as_binary, :marshal_dump, :marshal_load, :encode_with, :init_with, :area, :centroid, :point_on_surface, :is_simple?, :equals?, :disjoint?, :intersects?, :touches?, :crosses?, :within?, :contains?, :overlaps?, :relate?, :relate, :distance, :buffer, :convex_hull, :intersection, :union, :difference, :sym_difference, :-, :+, :*]

point
.class
=> RGeo::Cartesian::PointImpl

points
.methods - BasicObject.methods
=> [:distance, :buffer, :srid, :envelope, :x, :y, :z, :m, :dimension, :geometry_type, :is_empty?, :is_simple?, :boundary, :convex_hull, :equals?, :rep_equals?, :_copy_state_from, :_validate_geometry, :_set_factory, :factory, :as_text, :as_binary, :marshal_dump, :marshal_load, :encode_with, :init_with, :disjoint?, :intersects?, :touches?, :crosses?, :within?, :contains?, :overlaps?, :relate?, :relate, :intersection, :union, :difference, :sym_difference, :-, :+, :*]

point
.within? ward.first.geometry
RGeo::Error::UnsupportedOperation: Method Geometry#within? not defined.

ward
.first.include? point
NoMethodError: undefined method `include?' for #<RGeo::GeoJSON::Feature:0x007f84be24cb20>



Reply all
Reply to author
Forward
0 new messages