[postgis-users] Creating a Flow Diagram with PostGIS

Burgholzer,Robert rwburgholzer at deq.virginia.gov
Fri May 30 11:54:30 PDT 2008


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
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 4021 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080530/e0f8a4cd/attachment.bin>


More information about the postgis-users mailing list