[postgis-devel] topology expectations?

Sandro Santilli strk at keybit.net
Wed Mar 21 01:44:00 PDT 2012


On Tue, Mar 20, 2012 at 03:55:34PM -0700, Paul Ramsey wrote:
> How much should I expect from topology? I just took a polygon file
> that had contiguous non-overlapping polygons and did this:
> 
> cded=# select TopoGeo_AddPolygon('sheds', st_geometryn(geom,1), 5.0)
> from sheds where gis_tag like 'VICT%';
> 
> ERROR:  Spatial exception - geometry intersects edge 39
> CONTEXT:  PL/pgSQL function "topogeo_addlinestring" line 175 at assignment
> SQL statement "SELECT array_cat(edges, array_agg(x)) FROM ( select
> topology.TopoGeo_addLinestring(atopology, rec.geom, tol) as x ) as
> foo"
> PL/pgSQL function "topogeo_addpolygon" line 27 at assignment
> 
> This is a non-overlapping set of data, originally generated from
> vector clean ArcINFO coverages...
> 
> select a.gis_tag, b.gis_tag from sheds a, sheds b where
> st_overlaps(a.geom,b.geom) and a.gis_tag like 'VICT%' and b.gis_tag
> like 'VICT%';
> 
> (0 rows)
> 
> Thoughts?

It shouldn't happen. Can you share the data or a portion of it ?
The idea is that those functions never fail, at the possible cost of
giving you spaghetti result (hey, that's the official ISO/SQLMM term
for the result of ST_CreateTopoGeo, as reported by the author!).

Note that for non-overlapping data you probably don't need a big tolerance.
Tolerance uses ST_Snap which in turn is known to possibly introduce geometry
invalidities [1]. Not always snapping to the _closest_ item may also
introduce unpredictable outcomes.

[1] http://trac.osgeo.org/geos/ticket/501

Bottomline: you shouldn't expect 100% success during construction, but 
you can expect being able to construct incrementally thus fixing or working
around issues as you encounter it. Once the topology is built you can 
use more robust editing routines on the primitive level (SQLMM editing)

--strk;

  ,------o-. 
  |   __/  |    Delivering high quality PostGIS 2.0 !
  |  / 2.0 |    http://strk.keybit.net - http://vizzuality.com
  `-o------'




More information about the postgis-devel mailing list