在 Spatialite Query 的 RotateCoords 函数中使用质心函数时出现语法错误

Syntax error while using centroid function within the RotateCoords function in Spatialite Query

CREATE TABLE rotated_bus AS SELECT AO_id,
RotateCoords(ST_Centroid(Geometry) FROM Substation, 45.00) AS Geometry FROM Busbar;

我试图通过在 RotateCoords 函数中传递多边形几何体(变电站)的质心来旋转线几何体(母线)。在 运行 上面的查询之后,我得到一个错误“near FROM syntax error”。我的查询有什么问题?

您可以加​​入两个表:

CREATE TABLE rotated_bus AS
SELECT Busbar.AO_id,
       RotateCoords(ST_Centroid(Substation.Geometry), 45) AS Geometry
FROM Busbar
JOIN Substation ON Busbar.AO_id = Substation.Substn_ID

或者,使用 correlated subquery(子查询必须是一对额外括号内的完整查询):

CREATE TABLE rotated_bus AS
SELECT AO_id,
       (SELECT RotateCoords(ST_Centroid(Geometry), 45)
        FROM Substation
        WHERE Substn_ID = Busbar.AO_id
       ) AS Geometry
FROM Busbar