[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 19:17:30 PST 2009


Hi, Leo:

 

Thank you for your reply!

May be I did not tell my problem clearly,

Now, I want to know how i can get the number of points that stand for a polygon.

Just like the function of NumPoints(geometry) used for linestring.

 

And how can I locate each coordinate in the polygon?

Looking forward your reply!

Thanks a lot!

 

ZHANG Aiguo


 


From: lr at pcorp.us
To: postgis-users at postgis.refractions.net
Date: Wed, 11 Nov 2009 13:39:20 -0500
Subject: Re: [postgis-users] Can I replace all the x and y coordinates of a geometry using PostGIS, Thank you!




Not sure what you are trying to do, but one of the affine functions like ST_Translate may be what you are looking for.
 
http://www.postgis.org/documentation/manual-1.5SVN/ST_Translate.html
 
That will move all the points in the geometry a specified amount in x,y,z 
 
Leo
 



From: postgis-users-bounces at postgis.refractions.net [mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of ZHANGAIGUO
Sent: Wednesday, November 11, 2009 11:50 AM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] Can I replace all the x and y coordinates of a geometry using PostGIS, Thank you!


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



Messe nger保护盾2.0,更安全可靠的Messenger聊天! 现在就下载! 		 	   		  
_________________________________________________________________
MSN十周年庆典,查看MSN注册时间,赢取神秘大奖
http://10.msn.com.cn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20091112/9968ae67/attachment.html>


More information about the postgis-users mailing list