[postgis-users] Re: line interpolate point

George R. C. Silva georger.silva at gmail.com
Tue May 27 18:11:20 PDT 2008


Nevermind, got it to work fine.

This is the final code, so if anyone has a similar problem:
*
create or replace function interpola_centro(text,text,text) returns 
geometry as
$$

declare
geo_ponto geometry;
geometria geometry;
begin
geometria:= (select the_geom from logradouros where nomelog=$1 and 
prefixo_direcao=$2 and sufixo_direcao=$3) ;


geo_ponto := st_line_interpolate_point(st_geometryn(geometria,1),.5);


insert into teste(the_geom) values (geo_ponto);
return geo_ponto;
end;
$$
language plpgsql

*Thanks

George Silva




George R. C. Silva escreveu:
> Hello everyone!
>
> Once again i come to your expertise.
>
> I have a MULTILINESTRING layer (logradouros) and a test point layer.
>
> What i want to do is to locate the midpoint of a specific road and 
> place a point into it.
>
> Well, the roads layer have these informations nomelog(name of the 
> road), prefixo_direcao(intersection before that piece of road) and 
> sufixo_direcao(intersection after that piece of road).
>
> I want that this function selects the apropriate piece of road using 
> those fields, and then interpolate and insert the point to another layer.
> ----
> *create or replace function interpola_centro(text,text,text) returns 
> geometry as
> $$
>
> declare
> geo_ponto geometry;
> geometria geometry;
> sql varchar;
> begin
> sql:='select the_geom from logradouros where nomelog='||$1||' and 
> prefixo_direcao='||$2||' and sufixo_direcao='||$3 ;
>
> geometria := sql;
> geo_ponto := st_line_interpolate_point(st_geometryn(geometria,1),.5);
>
>
> insert into teste(the_geom) values (geo_ponto);
> return geo_ponto;
> end;
> $$
> language plpgsql
> ---
> *there is no problem with the function 'per se', but when i try to run 
> the function it gives me:
>
> ERROR:  parse error - invalid geometry
> CONTEXT:  PL/pgSQL function "interpola_centro" line 9 at assignment
>
> what is wrong?
>
> Thanks for your attention
>
> George Silva
>



More information about the postgis-users mailing list