[postgis-users] Creating a Flow Diagram with PostGIS

Paragon Corporation lr at pcorp.us
Sun Jun 1 14:34:03 PDT 2008


I'm also confused how does your below query update anything - how can id be
both 178 and 181?  Below were some other thoughts I had about what Robert
was saying.

Hopefully this helps more than confuses you.

1) I would first like to say that st_x, st_y, st_z only works with points.
So if you have other kinds of objects such as polygons or lines, then you
will need to probably do 

St_x(ST_Centroid(the_geom))  

2)  x1, y1, z1  in Robert's example represents the x, y, z coordinates of
your desired position (basically where do you want to move your object or if
talking about centroids, where do you want to reposition your object's
centroid)

3) Given that - I think the below is wrong - as you would end up moving all
your geometries into the same location which doesn't seem terribly
desirable.   It seems to me you would have an object on your canvas that you
would like moved and you want to maintain the same relative positions of the
items on the canvas that are attached to your moving object  by moving them
the same amount.  With that said here is a revised version

(Lets say x1, y1, z1  - for sake of argument is 1,2,3   basically you want
to move a ball so its centroid is at 1,2,3)  and you want to move all
objects attached to the ball an equal amount such that the relative
distances remain the same and lets say the gid of your ball is 1).  Note I
am assuming all things associated with the ball have the same parent code as
the ball.


UPDATE widget_table SET the_geom = ST_Translate(the_geom, xmove, ymove,
zmove) 
FROM (SELECT  (1 - 
st_x(ST_Centroid(the_geom))) As xmove, (2 - st_y(ST_Centroid(the_geom))) As
ymove, (3 - ST_Centroid(st_z(the_geom))) As zmove,
	parent_code
	FROM widget_table WHERE gid = 1) As the_moving_ball
WHERE widget_table.parent_code = the_moving_ball.parent_code;

Hope that helps,
Regina
 

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Bob
Pawley
Sent: Sunday, June 01, 2008 5:17 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Creating a Flow Diagram with PostGIS

Hi Robert

I managed to get the function working - in part.

      UPDATE graphics.process_dgm
        Set the_geom = translate(the_geom, (x1 - st_x(the_geom)), (y1 -
st_y(the_geom)))
 where graphics.process_dgm.id = '178'
 and graphics.process_dgm.id = '181';

This will move a point from one location to another depending on what I
insert into the x and y column.

But when I attempt to move the geometry that I want moved I get a message
"Argument to X() must be a point".

What am I doing wrong??

Bob




----- Original Message -----
From: "Burgholzer,Robert" <rwburgholzer at deq.virginia.gov>
To: "PostGIS Users Discussion" <postgis-users at postgis.refractions.net>
Sent: Friday, May 30, 2008 11:54 AM
Subject: [postgis-users] Creating a Flow Diagram with PostGIS


Bob,
I am taking this online, since it is relevant to PostGIS, and I want to make

sure that others review my comments for veracity

Original Question:
> At the moment I am importing dxf files, representing process and devices,
> into Postgis.
>
> Say I want to make two processes A & B.
>
>  I import the DXF graphic representing A and B into Postgis.
>
> I want B to be the first process and the output of B goes to A which is
> situated to the right of or below B.
>
> Using ST_Translate I need to know the distance in both x and y from the
> library to where I want to place the images and plug thos values into the
> Transform function. Perhaps there is a method of building a function to do
> this?
>
> Bob
>
>

My response:
You do not want to use transform for the location.  It has nothing to do 
with the location, only to the projection, i.e., spatial coordinate system. 
You DO want translate for location, however.  Transform might be useful if 
your objects are not imported from a standard library that you generate, or 
are not in the projection that you  wish to use for your interface.

CASE 1 (Objects are in same projection as your "Workspace"):
In this case, we don't really have to "know" where the starting location is,

since we have functions that can derive this.  Also, since our shapes are in

the same projection as the workspace, we only need the translate function. 
For this example, we are storing our components in a table called 
"widget_table", and the geometry column is "the_geom".  Let's assume that 
your original shape location coordinates are (x0, y0, z0), which can be 
obtained from the geometry column by using the function st_x, st_y, and 
st_z, and you want to move them to be located at (x1,y1,z1).  For this, the 
following translate call would work:

UPDATE widget_table SET the_geom = translate(the_geom, (x1 - 
st_x(the_geom)), (y1 - st_y(the_geom)), (z1 - st_z(the_geom))) ;

CASE 2 (you are importing user defined shapes, or shapes in disparate 
projections):
In this case you WOULD need transform(), to take them from whatever their 
source projection is, into whatever their base projection is, as follows 
(assuming that the workspace coordinate system is decimal degrees):

UPDATE widget_table SET the_geom = transform(the_geom, 4326);

Then, you would need to relocate them to some other point by using the 
function above.  That function could be encapsulated into its own PG 
function of course, something like relocate(x1,y1,z1) which would hide all 
of the calls to st_x,y and z.


The catch of course, is that it is essential that we KNOW the projection of 
our shapes before importing them.  That is actually the real sticky part 
here, not the movement of them.

HTH,
r.b.


Quoting Bob Pawley <rjpawley at shaw.ca>:

> Robert
>




----------------------------------------------------------------------------
----


> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
> 

_______________________________________________
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