From: Sandro Santilli Date: Fri, 27 Jan 2012 11:05:35 +0000 (+0000) Subject: Simplify the code looking for face containment in ST_AddIsoNode X-Git-Tag: 2.0.0alpha3~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=636925915ab800432872b0c4f54c5e99253c2d91;p=postgis Simplify the code looking for face containment in ST_AddIsoNode Fixes bug #1503 for me, altough I didn't handle to produce a testcase for it. git-svn-id: http://svn.osgeo.org/postgis/trunk@8941 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/topology/sql/sqlmm.sql.in.c b/topology/sql/sqlmm.sql.in.c index cb23c56ef..693c20f65 100644 --- a/topology/sql/sqlmm.sql.in.c +++ b/topology/sql/sqlmm.sql.in.c @@ -1538,38 +1538,26 @@ BEGIN -- -- probably there is something so now check the exact test -- - sql := 'SELECT e.face_id FROM (' - || 'SELECT d.face_id,ST_BuildArea(ST_Union(geom)) as geom FROM (' - || 'SELECT b.edge_id as edge_id,b.left_face as face_id,b.geom as geom FROM ' - || quote_ident(atopology) || '.edge_data as b,' - || '(SELECT a.face_id FROM ' - || quote_ident(atopology) || '.face as a ' - || 'WHERE ST_Intersects(a.mbr,' || quote_literal(apoint::text)||'::geometry)=true' - || ') as c ' - || 'WHERE (b.left_face = c.face_id) ' - || ' UNION ALL ' - || 'SELECT b.edge_id as edge_id, b.right_face as face_id, b.geom as geom FROM ' - || quote_ident(atopology) || '.edge_data as b,' - || '(SELECT a.face_id FROM ' - || quote_ident(atopology) || '.face as a ' - || 'WHERE ST_Intersects(a.mbr,' || quote_literal(apoint::text)||'::geometry)=true' - || ') as c ' - || 'WHERE (b.right_face = c.face_id) ' - || ') as d ' - || 'GROUP BY face_id ' - || ') as e ' - || 'WHERE ST_Intersects(e.geom, ' || quote_literal(apoint::text)||'::geometry)=true;'; - - --raise notice ' ==> %',sql; - BEGIN - EXECUTE sql INTO STRICT containingface; - EXCEPTION - WHEN NO_DATA_FOUND THEN - containingface = 0; - WHEN TOO_MANY_ROWS THEN - RAISE EXCEPTION 'Two or more faces found'; - END; - END IF; + sql := 'SELECT face_id FROM ' + || quote_ident(atopology) || '.face WHERE face_id > 0 AND mbr && ' + || quote_literal(apoint::text) || '::geometry AND ST_Contains(topology.ST_GetFaceGeometry(' + || quote_literal(atopology) || ', face_id), ' + || quote_literal(apoint::text) || '::geometry)'; +#ifdef POSTGIS_TOPOLOGY_DEBUG + RAISE DEBUG ' ==> %',sql; +#endif + BEGIN + EXECUTE sql INTO STRICT containingface; + EXCEPTION + WHEN NO_DATA_FOUND THEN +#ifdef POSTGIS_TOPOLOGY_DEBUG + RAISE DEBUG 'No faces contain point'; +#endif + containingface = 0; + WHEN TOO_MANY_ROWS THEN + RAISE EXCEPTION 'Two or more faces found'; + END; + END IF; -- -- Verify that aface contains apoint