PostgreSQL/PostGIS 无法在矩形多边形内搜索

PostgreSQL/PostGIS unable to search inside a rectangle polygon

我希望能够高效地查询矩形表面内的点。不幸的是,它似乎不起作用。

eykache=# SELECT * FROM colonies;
 id |                  location                  
----+--------------------------------------------
  1 | 010100000000000000000000000000000000000000
  2 | 010100000000000000000050400000000000005040
  3 | 010100000000000000000050400000000000000000
  4 | 0101000000000000000000504000000000000050C0
  5 | 0101000000000000000000000000000000000050C0
  6 | 010100000000000000000050C000000000000050C0
  7 | 010100000000000000000050C00000000000000000
(7 rows)

eykache=# SELECT id FROM colonies WHERE ST_Contains(colonies.location, ST_MakeEnvelope(-64, -64, 64, 64));
 id 
----
(0 rows)

如您所见,第二个响应是空的。

我只需要反转 ST_Contains 中的参数:

SELECT id FROM colonies WHERE ST_Contains(ST_MakeEnvelope(-64, -64, 64, 64), colonies.location);