[postgis-users] strange result of spatial functions

khorvat kresimir.horvat at in2.hr
Wed Nov 26 00:59:34 PST 2014


Before two days i had problem with conversion of MultiLineString to
LineString 
http://postgis.17.x6.nabble.com/st-union-and-st-linemerge-returns-multilinestring-td5007358.html
<http://postgis.17.x6.nabble.com/st-union-and-st-linemerge-returns-multilinestring-td5007358.html> 
. Later I found out that this problem appears with more spatial functions.

For eg. result I get from ST_LineMerge with geometry from database is
different then result of ST_LineMerge with geometry read as ST_GeomFromText
(they have same points, and are in same reference system).

Also I made small script that test geometries:

DO $$
DECLARE
	v_boundaryUnion		geometry;
	v_unitBoundary		geometry;
BEGIN
	SELECT ST_Union(b."Geometry")
		INTO v_boundaryUnion
		FROM myschema."Boundary" a
		INNER JOIN myschema."BoundaryGeom" b
			ON b."BoundaryId" = a."BoundaryId"
		WHERE a."UnitId" = 1;
	
	RAISE NOTICE 'BOUNDARY UNION: %', ST_AsText(v_boundaryUnion);
	
	
	SELECT ST_Boundary("Geometry")
		INTO v_unitBoundary
		FROM myschema."UnitGeom"
		WHERE "UnitId" = 1;
		
	RAISE NOTICE 'UNION BOUNDARY: %', ST_AsText(v_unitBoundary);
	
	
	IF ST_Equals(v_boundaryUnion, v_unitBoundary) THEN
		RAISE NOTICE 'EQUALS';
	ELSE
		RAISE NOTICE 'DIFFERENCE';
	END IF;
	
	v_boundaryUnion := ST_GeomFromWKB(ST_AsBinary(v_boundaryUnion), 3765);
	RAISE NOTICE 'UNION FROM WKB: %', ST_AsText(v_boundaryUnion);
	
	IF ST_Equals(v_boundaryUnion, v_unitBoundary) THEN
		RAISE NOTICE 'EQUALS';
	ELSE
		RAISE NOTICE 'DIFFERENCE';
	END IF;
	
	
	v_boundaryUnion := ST_GeomFromText(ST_AsText(v_boundaryUnion), 3765);
	RAISE NOTICE 'UNION FROM WKT: %', ST_AsText(v_boundaryUnion);
	
	IF ST_Equals(v_boundaryUnion, v_unitBoundary) THEN
		RAISE NOTICE 'EQUALS';
	ELSE
		RAISE NOTICE 'DIFFERENCE';
	END IF;
	
END $$;


result of this script is:
EQUALS
EQUALS
DIFFERENCE

Later on if I make operations with geometry from wkt i get expected results
(eq. ST_Difference), same as in JTS, and with original geometry I have some
really strange behaviour.

I don't have any idea why this thing happens. Metadata seems to be OK also:
f_table_name, f_geometry_column, coord_dimension, srid, type
"UnitGeom";"Geometry";2;3765;"GEOMETRY"
"BoundaryGeom";"Geometry";2;3765;"LINESTRING"

Any idea what could be wrong?




--
View this message in context: http://postgis.17.x6.nabble.com/strange-result-of-spatial-functions-tp5007385.html
Sent from the PostGIS - User mailing list archive at Nabble.com.


More information about the postgis-users mailing list