简体   繁体   中英

What is wrong with this ST_CONTAINS statement PostGIS - Find point in polygon

I'm trying the following:

Event.where('ST_Contains(?,ST_SetSRID(location, 4326)::geography)', search_polygon::geography)

add getting the error

*** NoMethodError Exception: undefined method `geography' for

but without that (::geography) I get a message telling me to cast, what do I do?

HINT: No function matches the given name and argument types. You might need to add explicit type casts.

It looks like you are trying to use ST_Contains on geography types, but that function only works on geometry types.

If you are OK with the intersects spatial relation (see DE-9IM ), then use ST_Intersects(geography, geography) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM