我執行以下查詢:
SELECT * FROM "houses" WHERE (ST_Distance(coordinates, 'POINT(-0.374930 39.478400)'::geometry) < 100)
查找距離以下 100 米的房屋:39.478400, -0.374930
我收到以下錯誤:
PG::InternalError: ERROR: Operation on mixed SRID geometries
這里有什么問題?
"Coordinates" is of type: geometry "coordinates", limit: {:srid=>4326, :type=>"geometry"}
謝謝你,圣誕快樂
uj5u.com熱心網友回復:
幾何字面'POINT(-0.374930 39.478400)'::geometry量沒有 SRID,而幾何體中houses.coordinates的 SRID 為4326。您需要傳遞具有相同 SRID 的幾何圖形,即使用ST_GeomFromText:
...
WHERE ST_Distance(coordinates, ST_GeomFromText('POINT(-0.374930 39.478400)', 4326)) < 100
但請記住,距離以 SRID 為單位回傳,SRID 4326 的單位是度,而不是米。要檢索以米為單位的距離,您可以使用ST_DistanceSphere。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/391454.html
標籤:PostgreSQL的 邮局
