<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial, helvetica, sans-serif;font-size:10pt"><div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;">Negative, i tried that with the below as the function declaration to no avail. The handle all higher levels section isn't finding anything in the arrays. Anyone else have a suggestion on how to store data within a function without creating a temporary table?<br><br>Curtis<br><br>CREATE OR REPLACE FUNCTION intersection_all(in_polys geometry, OUT id int, OUT intersection_count int, OUT the_geom geometry)<br> RETURNS SETOF record AS<br>$BODY$<br>DECLARE<br> total_count int := 0;<br> current_level_count int := 0;<br> first_id_of_previous_level int := 0;<br> last_id_of_previous_level int:= 0;<br> num_intersections int[];<br> geometries
geometry[];<br>BEGIN<br> -- handle level one by adding all input polygons<br> FOR i IN 1..NumGeometries(in_polys) LOOP<br> the_geom := GeometryN(in_polys,i);<br> intersection_count := 1;<br> geometries := array_append(geometries, the_geom);<br> num_intersections := array_append(num_intersections, intersection_count);<br> last_id_of_previous_level := last_id_of_previous_level+1;<br> total_count := total_count +1;<br> id := total_count;<br> RAISE NOTICE 'Inserting polygon number: % at level: %',total_count,1;<br> RETURN NEXT;<br> END LOOP;<br> <br> -- handle all higher
levels<br> FOR level IN 2..100 LOOP<br> RAISE NOTICE 'level: %',level;<br> FOR i IN first_id_of_previous_level..last_id_of_previous_level LOOP<br> RAISE NOTICE 'i: %',i;<br> FOR j IN (i+1) .. last_id_of_previous_level LOOP<br> RAISE NOTICE 'j: % last_id_of_previous_level: %',j,last_id_of_previous_level;<br> IF Intersects(geometries[i],geometries[j]) THEN<br> the_geom := Intersection(geometries[i],geometries[j]);<br>
intersection_count := level;<br> current_level_count := current_level_count+1;<br> geometries := array_append(geometries, temp_geom);<br> num_intersections := array_append(num_intersections, level);<br> total_count := total_count +1;<br> id := total_count;<br> RAISE NOTICE 'Inserting polygon number %',total_count;<br> RETURN
NEXT;<br> END IF;<br> END LOOP;<br> END LOOP;<br> IF current_level_count > 0 THEN<br> first_id_of_previous_level := last_id_of_previous_level+1;<br> last_id_of_previous_level := first_id_of_previous_level+current_level_count;<br> current_level_count := 0;<br> ELSE <br> EXIT;<br> END IF;<br> END LOOP;<br> <br> RETURN;<br>END;<br>$BODY$<br> LANGUAGE 'plpgsql' IMMUTABLE;<br><br><div style="font-family: times new roman,new
york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk><br>To: PostGIS Users Discussion <postgis-users@postgis.refractions.net><br>Sent: Tuesday, October 10, 2006 9:40:41 AM<br>Subject: Re: [postgis-users] Chained Intersections?<br><br><div>On Tue, 2006-10-10 at 06:22 -0700, Curtis W. Ruck wrote:<br><br>(cut)<br><br>> DECLARE<br>> total_count int := 0;<br>> current_level_count int := 0;<br>> first_id_of_previous_level int := 0;<br>> last_id_of_previous_level int:= 0;<br>> num_intersections int ARRAY[0];<br>> geometries geometry ARRAY[0];<br><br><br>Hi Curtis,<br><br>The declarations for num_intersections and geometries look strange - I'm<br>not sure the PostgreSQL parser can correctly determine they are arrays<br>from your
definitions. Can you try something like this:<br><br> num_intersections int[];<br> geometries geometry[];<br><br><br>Kind regards,<br><br>Mark.<br><br><br><br>_______________________________________________<br>postgis-users mailing list<br>postgis-users@postgis.refractions.net<br><a target="_blank" href="http://postgis.refractions.net/mailman/listinfo/postgis-users">http://postgis.refractions.net/mailman/listinfo/postgis-users</a><br></div></div><br></div></div></body></html>