这个 ST_CONTAINS 语句有什么问题 PostGIS - 在多边形中查找点

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

我正在尝试以下操作:

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

添加获取错误

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

但如果没有它 (::geography),我会收到一条消息,告诉我要投射,我该怎么办?

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

您似乎正尝试对地理类型使用 ST_Contains,但该功能仅适用于几何类型。

如果您对 intersects 空间关系满意(请参阅 DE-9IM), then use ST_Intersects(geography, geography)