[postgis-users] How to move polygons? (by new point or vector)

Marc Compte mcompte at sigte.udg.es
Tue Feb 6 06:50:02 PST 2007


Hi maciek,

I am trying to guess a way to do so and I haven't really check it 
myself, anyone correct me if I am wrong.

I believe you can use the translate function ( => 
Translate(geometry,float8,float8,float8)) to move a geometry. If I'm not 
wrong X and Y are not the final coordinates but the distance the polygon 
needs to move to get to your new coordinates.

In that case you could do something like:

1. User clics on the map. You should be able to get the coordinates of 
that particular point (Xpoint, Ypoint).
2. Calculate the centroid of the polygon to be moved using PostGIS's 
function => Centroid(geometry). This returns a point identifying the 
center of your polygon (Xcentroid, Ycentroid).
3. Calculate the distance on each of the axis between point and centroid
        DistanceX=Xpoint-Xcentroid
        DistanceY=Ypoint-Ycentroid
4. Move the polygon to the new location using 
Translate(geometry,DistanceX,DistanceY,0)

Hope this helps a bit,

Marc

En/na Maciej Skorczewski ha escrit:
> Hi all!
>
> is there any postgis function who can move polygon  on some vector?
>
>
> I store lot of polygons in database , user should move it in another 
> place. Is it posible to do?
>
>
> for ex. i show new point of map and then i punt selected polygon in 
> this palce.
>
> maciek
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>




More information about the postgis-users mailing list