[postgis-users] Creating a Flow Diagram

Andy Anderson aanderson at amherst.edu
Sun Jun 8 19:25:56 PDT 2008


On Jun 8, 2008, at 5:14 PM, Bob Pawley wrote:
> I 'm playing with a variation of the st_translate function we were  
> discussing last week.
>
> I have created two boxes (spatial_ref) and I wish to place an entity  
> (graphics.process_dgm) into the temp_ table with the coordinates  
> that centers the entity in a specific one of these boxes.
>
> Here's the code that I have come up with but so far it produces 0  
> rows.
>
> Insert into temp_ (the_geom)

> Select st_translate(st_translate (graphics.process_dgm.the_geom,
> st_y (st_centroid(graphics.process_dgm.the_geom)) - st_x  
> (st_centroid (spatial_ref.the_geom)),

The first function here should be "st_x", not "st_y".

> st_y (st_centroid(graphics.process_dgm.the_geom)) - st_y  
> (st_centroid (spatial_ref.the_geom))),
> ( st_xmax(graphics.process_dgm.the_geom) -  
> st_xmin(graphics.process_dgm.the_geom)),
> ( st_ymax(graphics.process_dgm.the_geom) -  
> st_ymin(graphics.process_dgm.the_geom)))

I don't see anything wrong with this, but you should be able to make a  
single st_translate call here since max - min won't change in a  
translation, e.g.

(st_y (st_centroid(graphics.process_dgm.the_geom)) - st_x (st_centroid  
(spatial_ref.the_geom))) + ( st_xmax(graphics.process_dgm.the_geom) -  
st_xmin(graphics.process_dgm.the_geom))

So after matching the centroids you're trying to move the lower left  
corner of the bounding box to its upper right corner?

> from graphics.process_dgm, spatial_ref, temp_

I don't think you need the ", temp_", but it probably doesn't hurt.

> where graphics.process_dgm.description = 'Tank'
> and spatial_ref.position_ = '2';

Is spatial_ref.position_ text? If it's an integer, drop the quotes.

-- Andy




More information about the postgis-users mailing list