]> granicus.if.org Git - postgis/commitdiff
Fix toTopoGeom to actualy _use_ to given tolerance (#1647)
authorSandro Santilli <strk@keybit.net>
Tue, 6 Mar 2012 09:05:00 +0000 (09:05 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 6 Mar 2012 09:05:00 +0000 (09:05 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@9404 b70326c6-7e19-0410-871a-916f4a2858ee

topology/sql/topogeometry/totopogeom.sql.in.c
topology/test/regress/totopogeom.sql
topology/test/regress/totopogeom_expected

index 006a6566d378e308a552ddd6371303d3e57b2f85..3b7ee6bd0327cf9e85ce312912eb7344f2b33596 100644 (file)
@@ -43,7 +43,7 @@ BEGIN
   END;
 
   -- Get tolerance, if 0 was given
-  tolerance := COALESCE( NULLIF(tolerance, 0), topology._st_mintolerance(atopology, ageom) );
+  tolerance := COALESCE( NULLIF(atolerance, 0), topology._st_mintolerance(atopology, ageom) );
 
   -- Get layer information
   BEGIN
index 4f5fe68dd258874a64a21f80b6c9e49d71e28f74..ff44efa08053dbe794f196f5a9f211f0c623560c 100644 (file)
@@ -95,6 +95,42 @@ SELECT ST_AsText(toTopoGeom('POLYGON EMPTY', 'tt', 4)::geometry);
 SELECT ST_AsText(toTopoGeom('MULTIPOLYGON EMPTY', 'tt', 4)::geometry);
 SELECT ST_AsText(toTopoGeom('GEOMETRYCOLLECTION EMPTY', 'tt', 5)::geometry);
 
+-- Test with tolerance (expect to snap to POINT(-100 -100)
+with inp as ( select
+'GEOMETRYCOLLECTION(
+ POINT(-100 -100.5),
+ LINESTRING(-100 -90,-90 -90.5),
+ POLYGON((-100 -80,-89.5 -80,-95 -70,-100 -80),(-98 -78,-92 -78,-95 -72.5,-98 -78))
+)'
+ ::geometry as g),
+tg as ( select totopogeom(g, 'tt', 5, 1) as g from inp )
+select 'tolerance_1', ST_HausdorffDistance(inp.g, tg.g::geometry) FROM inp, tg;
+
+-- Test with tolerance specified in topology record
+UPDATE topology.topology SET precision=1 WHERE name = 'tt';
+with inp as ( select
+'GEOMETRYCOLLECTION(
+ POINT(-100 -100.5),
+ LINESTRING(-100 -90,-90 -90.5),
+ POLYGON((-100 -80,-89.5 -80,-95 -70,-100 -80),(-98 -78,-92 -78,-95 -72.5,-98 -78))
+)'
+ ::geometry as g),
+tg as ( select totopogeom(g, 'tt', 5) as g from inp )
+select 'tolerance_topo_1', ST_HausdorffDistance(inp.g, tg.g::geometry) FROM inp, tg;
+
+-- Test without tolerance (expect to remain POINT(-100 -100.5)
+UPDATE topology.topology SET precision=0 WHERE name = 'tt';
+with inp as ( select
+'GEOMETRYCOLLECTION(
+ POINT(-100 -100.5),
+ LINESTRING(-100 -90,-90 -90.5),
+ POLYGON((-100 -80,-89.5 -80,-95 -70,-100 -80),(-98 -78,-92 -78,-95 -72.5,-98 -78))
+)'
+ ::geometry as g),
+tg as ( select totopogeom(g, 'tt', 5) as g from inp )
+select 'tolerance_0', ST_HausdorffDistance(inp.g, tg.g::geometry) FROM inp, tg;
+
+
 DROP TABLE tt.f_coll;
 DROP TABLE tt.f_areal;
 DROP TABLE tt.f_lineal;
index 22dce3ea715ae1427d1f60430c6f18870f27dbaa..ad420743692455f960c780ea39385a250eda5abf 100644 (file)
@@ -29,4 +29,7 @@ MULTILINESTRING EMPTY
 MULTIPOLYGON EMPTY
 MULTIPOLYGON EMPTY
 GEOMETRYCOLLECTION EMPTY
+tolerance_1|0.5
+tolerance_topo_1|0.5
+tolerance_0|0
 Topology 'tt' dropped