You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm fairly certain that I'm doing something wrong here but when using a the active-record rgeo gem and encoding a single polygon, I'm able to make a db query like this:
This works: MyModel.where("latlon && ?", poly) where the latlon column is a point type and the poly represents a regular polygon that I generated from a linestring of coordinates using this factory: factory = RGeo::Geographic.spherical_factory(:srid => 4326)
This doesn't:
Using this gem, I encode a geojson multipolygon successfully using: poly = RGeo::GeoJSON.decode(mp.to_json, :json_parser => :json) Then I extract the geometry using: poly = poly.geometry and that also seems to be successful. Now I try to run that same query from above: MyModel.where("latlon && ?", poly) but this time it fails with this error:
PG::DatatypeMismatch at /api/v1/listings/polygon_search.json
============================================================
> ERROR: argument of WHERE must be type boolean, not type record
LINE 1: SELECT "my_models".* FROM "my_model" WHERE (latlon && '002000...
The text was updated successfully, but these errors were encountered:
I think I've figured this out. I suppose I just have to iterate through each of the polygons in the multi_polygon and check results for each one. Unless anyone knows of a better way?
The exception was being raised because the multi_polygon is actually multiple polygon types.... Obvious in hindsight!
I think I've figured this out. I suppose I just have to iterate through each of the polygons in the multi_polygon and check results for each one. Unless anyone knows of a better way?
I'm fairly certain that I'm doing something wrong here but when using a the active-record rgeo gem and encoding a single polygon, I'm able to make a db query like this:
This works:
MyModel.where("latlon && ?", poly)
where thelatlon
column is apoint
type and thepoly
represents a regular polygon that I generated from a linestring of coordinates using this factory:factory = RGeo::Geographic.spherical_factory(:srid => 4326)
This doesn't:
Using this gem, I encode a geojson multipolygon successfully using:
poly = RGeo::GeoJSON.decode(mp.to_json, :json_parser => :json)
Then I extract the geometry using:poly = poly.geometry
and that also seems to be successful. Now I try to run that same query from above:MyModel.where("latlon && ?", poly)
but this time it fails with this error:The text was updated successfully, but these errors were encountered: