<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Windows-1252">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.0.6619.12">
<TITLE>RE: [postgis-users] Creating a Flow Diagram with PostGIS</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Thanks for the clarifications and corrections Regina.<BR>
<BR>
There was a mistake in my query, since I should have been taking the st_x(centroid(the_geom)) (and st_y, st_z), since they were not point geometries. <BR>
<BR>
She is also correct about moving both geometries 178 and 181 to the same point, in which case they would be overlapping.  Her query should work as well, however, if you do not have the parent:child relationships that her query assumes, you could accomplish the same by the following:<BR>
<BR>
UPDATE graphics.process_dgm SET the_geom = ST_Translate(the_geom, xmove, ymove,<BR>
zmove)<BR>
FROM (SELECT  (1 -<BR>
st_x(ST_Centroid(the_geom))) As xmove, (2 - st_y(ST_Centroid(the_geom))) As<BR>
ymove, (3 - ST_Centroid(st_z(the_geom))) As zmove<BR>
        FROM graphics.process_dgm.id WHERE graphics.process_dgm.id = 178) As the_moving_ball<BR>
WHERE graphics.process_dgm.id in (178,181);<BR>
<BR>
<BR>
HTH,<BR>
r.b.<BR>
<BR>
<BR>
-----Original Message-----<BR>
From:   postgis-users-bounces@postgis.refractions.net on behalf of Paragon Corporation<BR>
Sent:   Sun 6/1/2008 5:34 PM<BR>
To:     'PostGIS Users Discussion'<BR>
Cc:    <BR>
Subject:        RE: [postgis-users] Creating a Flow Diagram with PostGIS<BR>
<BR>
I'm also confused how does your below query update anything - how can id be<BR>
both 178 and 181?  Below were some other thoughts I had about what Robert<BR>
was saying.<BR>
<BR>
Hopefully this helps more than confuses you.<BR>
<BR>
1) I would first like to say that st_x, st_y, st_z only works with points.<BR>
So if you have other kinds of objects such as polygons or lines, then you<BR>
will need to probably do<BR>
<BR>
St_x(ST_Centroid(the_geom)) <BR>
<BR>
2)  x1, y1, z1  in Robert's example represents the x, y, z coordinates of<BR>
your desired position (basically where do you want to move your object or if<BR>
talking about centroids, where do you want to reposition your object's<BR>
centroid)<BR>
<BR>
3) Given that - I think the below is wrong - as you would end up moving all<BR>
your geometries into the same location which doesn't seem terribly<BR>
desirable.   It seems to me you would have an object on your canvas that you<BR>
would like moved and you want to maintain the same relative positions of the<BR>
items on the canvas that are attached to your moving object  by moving them<BR>
the same amount.  With that said here is a revised version<BR>
<BR>
(Lets say x1, y1, z1  - for sake of argument is 1,2,3   basically you want<BR>
to move a ball so its centroid is at 1,2,3)  and you want to move all<BR>
objects attached to the ball an equal amount such that the relative<BR>
distances remain the same and lets say the gid of your ball is 1).  Note I<BR>
am assuming all things associated with the ball have the same parent code as<BR>
the ball.<BR>
<BR>
<BR>
UPDATE widget_table SET the_geom = ST_Translate(the_geom, xmove, ymove,<BR>
zmove)<BR>
FROM (SELECT  (1 -<BR>
st_x(ST_Centroid(the_geom))) As xmove, (2 - st_y(ST_Centroid(the_geom))) As<BR>
ymove, (3 - ST_Centroid(st_z(the_geom))) As zmove,<BR>
        parent_code<BR>
        FROM widget_table WHERE gid = 1) As the_moving_ball<BR>
WHERE widget_table.parent_code = the_moving_ball.parent_code;<BR>
<BR>
Hope that helps,<BR>
Regina<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: postgis-users-bounces@postgis.refractions.net<BR>
[<A HREF="mailto:postgis-users-bounces@postgis.refractions.net">mailto:postgis-users-bounces@postgis.refractions.net</A>] On Behalf Of Bob<BR>
Pawley<BR>
Sent: Sunday, June 01, 2008 5:17 PM<BR>
To: PostGIS Users Discussion<BR>
Subject: Re: [postgis-users] Creating a Flow Diagram with PostGIS<BR>
<BR>
Hi Robert<BR>
<BR>
I managed to get the function working - in part.<BR>
<BR>
      UPDATE graphics.process_dgm<BR>
        Set the_geom = translate(the_geom, (x1 - st_x(the_geom)), (y1 -<BR>
st_y(the_geom)))<BR>
 where graphics.process_dgm.id = '178'<BR>
 and graphics.process_dgm.id = '181';<BR>
<BR>
This will move a point from one location to another depending on what I<BR>
insert into the x and y column.<BR>
<BR>
But when I attempt to move the geometry that I want moved I get a message<BR>
"Argument to X() must be a point".<BR>
<BR>
What am I doing wrong??<BR>
<BR>
Bob<BR>
<BR>
<BR>
<BR>
<BR>
----- Original Message -----<BR>
From: "Burgholzer,Robert" <rwburgholzer@deq.virginia.gov><BR>
To: "PostGIS Users Discussion" <postgis-users@postgis.refractions.net><BR>
Sent: Friday, May 30, 2008 11:54 AM<BR>
Subject: [postgis-users] Creating a Flow Diagram with PostGIS<BR>
<BR>
<BR>
Bob,<BR>
I am taking this online, since it is relevant to PostGIS, and I want to make<BR>
<BR>
sure that others review my comments for veracity<BR>
<BR>
Original Question:<BR>
> At the moment I am importing dxf files, representing process and devices,<BR>
> into Postgis.<BR>
><BR>
> Say I want to make two processes A & B.<BR>
><BR>
>  I import the DXF graphic representing A and B into Postgis.<BR>
><BR>
> I want B to be the first process and the output of B goes to A which is<BR>
> situated to the right of or below B.<BR>
><BR>
> Using ST_Translate I need to know the distance in both x and y from the<BR>
> library to where I want to place the images and plug thos values into the<BR>
> Transform function. Perhaps there is a method of building a function to do<BR>
> this?<BR>
><BR>
> Bob<BR>
><BR>
><BR>
<BR>
My response:<BR>
You do not want to use transform for the location.  It has nothing to do<BR>
with the location, only to the projection, i.e., spatial coordinate system.<BR>
You DO want translate for location, however.  Transform might be useful if<BR>
your objects are not imported from a standard library that you generate, or<BR>
are not in the projection that you  wish to use for your interface.<BR>
<BR>
CASE 1 (Objects are in same projection as your "Workspace"):<BR>
In this case, we don't really have to "know" where the starting location is,<BR>
<BR>
since we have functions that can derive this.  Also, since our shapes are in<BR>
<BR>
the same projection as the workspace, we only need the translate function.<BR>
For this example, we are storing our components in a table called<BR>
"widget_table", and the geometry column is "the_geom".  Let's assume that<BR>
your original shape location coordinates are (x0, y0, z0), which can be<BR>
obtained from the geometry column by using the function st_x, st_y, and<BR>
st_z, and you want to move them to be located at (x1,y1,z1).  For this, the<BR>
following translate call would work:<BR>
<BR>
UPDATE widget_table SET the_geom = translate(the_geom, (x1 -<BR>
st_x(the_geom)), (y1 - st_y(the_geom)), (z1 - st_z(the_geom))) ;<BR>
<BR>
CASE 2 (you are importing user defined shapes, or shapes in disparate<BR>
projections):<BR>
In this case you WOULD need transform(), to take them from whatever their<BR>
source projection is, into whatever their base projection is, as follows<BR>
(assuming that the workspace coordinate system is decimal degrees):<BR>
<BR>
UPDATE widget_table SET the_geom = transform(the_geom, 4326);<BR>
<BR>
Then, you would need to relocate them to some other point by using the<BR>
function above.  That function could be encapsulated into its own PG<BR>
function of course, something like relocate(x1,y1,z1) which would hide all<BR>
of the calls to st_x,y and z.<BR>
<BR>
<BR>
The catch of course, is that it is essential that we KNOW the projection of<BR>
our shapes before importing them.  That is actually the real sticky part<BR>
here, not the movement of them.<BR>
<BR>
HTH,<BR>
r.b.<BR>
<BR>
<BR>
Quoting Bob Pawley <rjpawley@shaw.ca>:<BR>
<BR>
> Robert<BR>
><BR>
<BR>
<BR>
<BR>
<BR>
----------------------------------------------------------------------------<BR>
----<BR>
<BR>
<BR>
> _______________________________________________<BR>
> postgis-users mailing list<BR>
> postgis-users@postgis.refractions.net<BR>
> <A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
><BR>
<BR>
_______________________________________________<BR>
postgis-users mailing list<BR>
postgis-users@postgis.refractions.net<BR>
<A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
<BR>
<BR>
_______________________________________________<BR>
postgis-users mailing list<BR>
postgis-users@postgis.refractions.net<BR>
<A HREF="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</A><BR>
<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>