我想在 pl/python3/postgis 中创建一个函数,它返回一组几何记录(例如点)。我设法用我的点的坐标创建了一个字典,但我不知道如何将它们变成实际的 postgis“点”几何。到目前为止,这是我的代码:
CREATE OR REPLACE FUNCTION grid_points()
RETURNS text AS
$$
grid_cell_length_x = 2
grid_cell_length_y = 1
grid_points = {}
for i in range(0, 3):
for j in range(0,3):
key = "grid_poin_" + str(i) + "" + str(j)
x = 5 + i * grid_cell_length_x
y = 10 - j * grid_cell_length_y
value = (x, y)
grid_points[key] = value
return(
grid_points)
$$
LANGUAGE plpython3u;
select grid_points();