[postgis-users] TopologyException in GEOS ST_Union function

fsalas at geocuba.cu fsalas at geocuba.cu
Thu Jun 9 11:03:04 PDT 2011


TopologyException in GEOS ST_Union function

I'm writting a function using the plpgsql language in PostgreSQL.
This function operate with geometries and I do something like this:

-- Open a cursor for a table

OPEN veget_cursor FOR
	SELECT gid, wkb_geometry as the_geom
	FROM table_v;
LOOP
	FETCH veget_cursor INTO _gid, veget_geom;

	-- Validate the geometry of the table table_v

	IF ST_isvalid(veget_geom) THEN

		-- Open a cursor for a selection. The selection only contains the  
geometries that intersects
		-- with the current geometry of the cursor veget_cursor.

		OPEN floor_cursor FOR
			SELECT gid, wkb_geometry as the_geom
				FROM table_f
				WHERE ST_Intersects(wkb_geometry, veget_geom);
			LOOP
				FETCH floor_cursor INTO f3, floor_geom;

				-- Validate the geometry of the other table (table_f)

				IF ST_isvalid(floor_geom) THEN

					-- Intersects the geometries of the two cursors

					geom := ST_Intersection(floor_geom, veget_geom);

					-- Validate the resultant geometry of the intersection operation

					IF (ST_Isvalid(geom)) THEN

					-- Here join the geometry of geom into union_geom

							IF union_geom IS NULL THEN
								union_geom := geom;
							ELSE
								union_geom := st_union(union_geom, geom);
							END IF;
					END IF;

				END IF;
			END LOOP;
		CLOSE floor_cursor;
END LOOP;
CLOSE veget_cursor;

This code throw a topology exception:
TopologyException: found non-noded intersection between -83.5325  
22.7268, -83.5327 22.7271 and -83.5327 22.7269, -83.5325 22.7268  
-83.5325 22.7268
ERROR:  GEOS union() threw an error!

The questions are:
- Why does it throw an exception if I'm validating all geometries?
- What does the exception mean?
- What can I do?

Best regards, Salas




More information about the postgis-users mailing list