Get around the NULL geometry by removing the z arguments in the
translate functions for the NON 3d geometries.

Attached is the working implementation, enjoy!



> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Sufficool, Stanley
> Sent: Thursday, June 05, 2008 11:16 AM
> To: PostGIS Users Discussion
> Subject: RE: [postgis-users] Creating a Flow Diagram
> 
> 
> OK, I'm trying to come up with a solid solution to all this 
> since it roughly applies to some things I'm doing with 
> attached objects and location tracking.
> 
> This rule is resulting in infinite recursion when there is no 
> reason for the rule to even execute. 
> 
> Am I understanding the rules system wrong or should this be a 
> trigger function?
> 
> -------------------
> 
> create or replace rule entity_update AS ON update TO entity 
> WHERE NOT (st_AsText(OLD.the_geom) ~= 
> st_AsText(NEW.the_geom)) -- Only if geometry was modifed (I'm 
> sure there is a more appropriate operator
> here)
> DO UPDATE entity 
>       SET the_geom = st_translate(
>               -- Center the child on parent geometry
>               st_translate( 
>                       the_geom, 
>                       st_x(st_centroid(NEW.the_geom)) - 
> st_x(st_centroid(the_geom)),  
>                       st_y(st_centroid(NEW.the_geom)) - 
> st_y(st_centroid(the_geom)),
>                       st_z(st_centroid(NEW.the_geom)) -
> st_z(st_centroid(the_geom))           
>               ),
>               --Translate to relative position of parent 
>               ( st_xmax(NEW.the_geom) - st_xmin(NEW.the_geom) ) *
> ratio_x,
>               ( st_ymax(NEW.the_geom) - st_ymin(NEW.the_geom) ) *
> ratio_y,
>               ( st_zmax(NEW.the_geom) - st_zmin(NEW.the_geom) ) *
> ratio_z
>       )
>       WHERE parent_entity_id = NEW.entity_id  --Update all children of
> the modified parent record
> ;
> 
> -- NOW LETS touch the parent
> update entity SET the_geom = st_translate(the_geom, 0, 0) 
> where entity_id = (SELECT MIN(entity_id) FROM entity)
> 
> 
> ERROR:  infinite recursion detected in rules for relation "entity"
> 
> ********** Error **********
> 
> ERROR: infinite recursion detected in rules for relation 
> "entity" SQL state: 42P17
> 

Attachment: diagram2.sql
Description: diagram2.sql

_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to