[postgis-users] Can I replace all the x and y coordinates of a geometry using PostGIS, Thank you!

ZHANGAIGUO chnyhn at hotmail.com
Wed Nov 11 08:50:27 PST 2009


Hello Postgis-users:

I am a student in Fuzhou University, China.
In using PostGIS,
I encountered a problem as fellows:
How can I replace all the x and y coordinates of a geometry?
The geometry may be point, multipoint, linestring, multilinestring, and so on.
I have tried to use the way as fellows:

CREATE OR REPLACE FUNCTION aigo_coord_offset_basicframe2(geometry, double precision, double precision)
   RETURNS geometry AS
 $BODY$
 declare i integer; 
 compress geometry; 
geom1 geometry;
 begin
 i:=1;
 geom1:=ST_GeomFromText('LINESTRING(0 0, 0.0001 0.0001)',21460);
 while i<= ST_NumPoints($1) loop
 geom1:=ST_AddPoint(geom1,ST_MakePoint(int2(ST_X(ST_PointN($1,i))-$2),int2(ST_Y(ST_PointN($1,i))-$3)));
 i:=i+1;
 end loop;
 geom1:=ST_RemovePoint(geom1,0);
geom1:=ST_RemovePoint(geom1,0);
compress:=geom1;
return compress;
end $BODY$
   LANGUAGE 'plpgsql' VOLATILE
  COST 100;
 ALTER FUNCTION aigo_coord_offset_basicframe2(geometry, double precision, double precision) OWNER TO post;
 
 The way above is just applied to LINESTRING geometry type,
 and it is inefficient.
 
 Are there any other solutions to accomplish it?
 Thank you!

 Sincerely Yours!
 ZHANG Aiguo
 		 	   		  
_________________________________________________________________
MSN十周年庆典,查看MSN注册时间,赢取神秘大奖
http://10.msn.com.cn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20091112/693c4757/attachment.html>


More information about the postgis-users mailing list