[postgis-users] Creating a Flow Diagram

Andy Anderson aanderson at amherst.edu
Mon Jun 9 15:26:10 PDT 2008


What do you get if you just use

	Select st_asText(graphics.process_dgm.the_geom),  
st_asText(spatial_ref.the_geom)
		from graphics.process_dgm, spatial_ref
			where graphics.process_dgm.description = 'Tank' and  
spatial_ref.position_ = 2 ;

?

If you get something, build up from there until it breaks.

-- Andy

On Jun 9, 2008, at 12:23 PM, Bob Pawley wrote:

> Andy
>
> I've been trying the changes you suggested without success.
>
> I get an error when I use the + operator (and also if I leave out  
> temp_).
>
> Perhaps I don't understand the use of st_y, st_x max and min.
>
> I don't want to change the entity merley move it from where it is to  
> the center of an established geometry (box).
>
> Here's the function as it now stands. I still get 0 rows affected  
> and the two tables do have geometries (one entity in process_dgm and  
> one box in spatial_ref where position = 2) in them.
>
> Insert into temp_ (the_geom)
> Select st_translate (st_translate(graphics.process_dgm.the_geom,
> st_x (st_centroid(graphics.process_dgm.the_geom)) - st_x  
> (st_centroid (spatial_ref.the_geom)),
> 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)))
>
> from graphics.process_dgm, spatial_ref, temp_
> where graphics.process_dgm.description = 'Tank'
> and spatial_ref.position_ = 2 ;
>
> Bob
>
>
> ----- Original Message ----- From: "Andy Anderson" <aanderson at amherst.edu 
> >
> To: "PostGIS Users Discussion" <postgis-users at postgis.refractions.net>
> Sent: Sunday, June 08, 2008 7:25 PM
> Subject: Re: [postgis-users] Creating a Flow Diagram
>
>
>> 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