AW: [postgis-users]postgis database connection failed.

Rene Neidt r.neidt at
Fri Aug 4 01:33:46 PDT 2006

Hi all ...,

We are creating an application with height requirements for geometric /
geographical functions. We decided to use postgres/postgis:
version(): "PostgreSQL 8.1.2 on i686-pc-mingw32, compiled by GCC gcc.exe
(GCC) 3.4.2 (mingw-special)"
gostgis_version(): "1.1 USE_GEOS=1 USE_PROJ=1 USE_STATS=1"

The features are really great and the performance is ok. But again we have
trouble with the geos - functions (GEOS Intersection() threw an error! (or
union or difference)). The reason seems to be a little inaccuracy in the
coordinates, that accures while converting, intersecting, ... the
geometries. For demonstration following example:
Geometry1: GeometryFromText('MULTIPOLYGON(((5415144.13 5665163.17,5415155.58
5665159.46,5415167.78 5665155.72,5415173.02 5665153.58,5415185.57
5665172.69,5415167.07 5665187.86,5415157.12 5665174.96,5415144.13


(Sorry for the complex geometries, but with Polygon((1 0, 0 1, 1 1, 1 0))...
the problems do not occur.)
select intersection(Gemetry1, Geometry2) 
->raises the error: 
NOTICE:  TopologyException: no outgoing dirEdge found
GEOS Intersection() threw an error!


select intersection(Gemetry1, asText(Geometry2)) 
-> works fine!

Probably because of converting the geometry the coordinates are a little bit
different, so that the error does not occur.

The last tip we got, was allways to use SnapToGrid. But we can not do. To
demonstrate this, the two pictures:
Input: We have the red polygon and the blue line. Both are "snaped to the
grid". We want to devide the polygon into two parts by "cutting it with the
line" (in our application we do not cut with a line, we use a polygon which
overlays one part of the red polygon, so we can use intersection and

The output of such a division would be the two green polygons (output.gif),
which are allready snapped to grid (We have to snap them too, because maybe
in the next moment one of them will be devided again...). And when we
compare the union of both green polygons with the red polygon, it will not
be the same. And so we will get holes (many of the red polygons adjoin each
other an form a big polygon, which should not have holes...)
I hope, you could understand, what we meant...

So at the moment our workaround is to encapsulate the geos - functions. At
first we try a intersection(geometry1, geometry2). If this raises an
exception, we try intersection(asText(geometry1), asText(geometry2)). In the
cases we had up to now it worked, but I am not sure, whether it will allways

In our opinion it is necessary to have a tollerance for the geos -
functions, which could be set as a parameter.

Thank you in advance,
Thomas and Rene

-------------- next part --------------
A non-text attachment was scrubbed...
Name: output.gif
Type: image/gif
Size: 2240 bytes
Desc: not available
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: input.gif
Type: image/gif
Size: 2098 bytes
Desc: not available
URL: <>

More information about the postgis-users mailing list