Skip to content

DatatypeMismatch with db queries using multipolygons #30

@Siggs2000

Description

@Siggs2000

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...
            

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationIssues that could be solved by adding documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions