如何转移点的X和Y的值? [英] How could I transfer the value of point's X and Y?
本文介绍了如何转移点的X和Y的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
功能如下:
create or replace function point_to_M(x float,y float, i integer)
returns float AS
$$
DECLARE
geo geometry;
geo1 geometry;
begin
select testo.geom into geo from testo where lineid=i;
geo1=st_astext(st_line_interpolate_point(st_geometryN(geo,1),'point(x y)')');
return st_X(geo1);
end;
$$
language plpgsql;
当我输入SQL时:
when I input the SQL:
select point_to_M(80,0,0);
错误是:
ERROR: invalid input syntax for type double precision: "point(x y)"
LINE 1: ...ext(st_line_interpolate_point(st_geometryN(geo,1),'point(x y...
所以我认为原因可能是参数没有转移到函数中,但是我不确定,所以有人有这个问题吗?你能告诉我解决方案吗?非常感谢.
So I think the reason maybe is that the paramater didn't transfer into the function, but I am not sure, so does anyone had this problem? Could you tell me the solution? Thanks very much.
推荐答案
只需将经纬度长点转换为点
Just convert lat long to point
create or replace function point_to_M(x float,y float, i integer)
returns float AS
$$
DECLARE
geo geometry;
geo1 geometry;
begin
select testo.geom into geo from testo where lineid=i;
geo1=st_astext(st_line_interpolate_point(st_geometryN(geo,1),st_makepoint(x y)));
return st_X(geo1);
end;
$$
language plpgsql;
这篇关于如何转移点的X和Y的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文