[postgis-devel] [PostGIS] #1613: Cannot achieve toTopoGeom

PostGIS trac at osgeo.org
Tue Feb 28 06:25:35 PST 2012


#1613: Cannot achieve toTopoGeom
----------------------+-----------------------------------------------------
 Reporter:  3nids     |       Owner:  strk         
     Type:  defect    |      Status:  assigned     
 Priority:  medium    |   Milestone:  PostGIS 2.0.0
Component:  topology  |     Version:  2.0.x        
 Keywords:            |  
----------------------+-----------------------------------------------------

Comment(by strk):

 Ok, what's happening is that the code fails snapping the first line to the
 intersection with the second line.

 Try this:

 {{{
 select ST_AsText(ST_Snap('LINESTRING(556267.562954 144887.066638,556267
 144887.4)'::geometry, 'POINT(556267.55881132 144887.069091153)'::geometry,
 1e-12));
 }}}

 You'll see the edge remains a 2-points edge.

 1e-12 is an arbitrary tolerance hard-coded into the TopoGeo_AddPoint, only
 because ST_Snap needs a tolerance to do its thing. If you make it bigger
 you get the 3-vertex result. If you make it too big it gets back to 2
 vertex snapping to the first vertex whose distance is below the tolerance.

 Not an easy problem to solve. The whole reason to snap is because the
 ST_ModEdgeSplit (and ST_NewEdgesSplit) insist on the "splitting-vertex" to
 be _within_ the edge, which is close to impossible to achieve... The
 SQL/MM specs do not include any reference about accepting tolerances in
 there.

 Finally, it turns out that ST_Within and ST_DWithin(0) disagree about the
 matter being:

 {{{
 is '010100000070841C1ED7F9204187A97F8DB8AF0141'::geometry
 within
 '010200000002000000B6813B20D7F92041F5807988B8AF014100000000D6F9204133333333BBAF0141'::geometry
 ?
 }}}

 So bottomline:

 {{{
 =# with inp as ( select
 '010100000070841C1ED7F9204187A97F8DB8AF0141'::geometry as p,
 '010200000002000000B6813B20D7F92041F5807988B8AF014100000000D6F9204133333333BBAF0141'::geometry
 as l ) select ST_AsText(l) as l, ST_AsText(p) as p, ST_Within(p, l) as
 within, ST_DWithin(p, l, 0) as dwithin from inp;
 -[ RECORD 1 ]----------------------------------------------------
 l       | LINESTRING(556267.562954 144887.066638,556267 144887.4)
 p       | POINT(556267.55881132 144887.069091153)
 within  | f
 dwithin | t
 }}}

 Worth a sub-ticket

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/1613#comment:4>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-devel mailing list