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

Rene Neidt r.neidt at idu.de
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
5665163.17)))')

Geometry2:
'010300000001000000150000006C9BD9273DA854411F2D0B86619C55412913FA603DA854413
78478B7619C5541B5075B743DA85441F4B287B1619C5541BE0C12833DA8544136D767BE619C5
5414C0D12833DA85441CCD767BE619C5541BA0D12833DA854417AD867BE619C5541F80D12833
DA854411AD967BE619C5541000000F03FA854419A9999F9609C554114AE474141A8544152B81
E65609C55411A0BD67443A85441398640BF639C55410CF5E3B843A854416D104AB2639C55415
982C67641A854416FFEFC41609C5541E9DFDF6E41A85441E8183538609C55414FBD366541A85
441AAF62830609C5541958E2A5A41A854410B1B282A609C5541D77B284E41A854411BD76D266
09C5541BB2AA74141A854418EFF1E25609C5541282A223541A85441D3804826609C55416D2D1
52941A8544164DFDE29609C5541560666DC3FA85441B3E0BCB1609C55416C9BD9273DA854411
F2D0B86619C5541'

(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
(5.41516e+006,5.66516e+006,5.66516e+006)
GEOS Intersection() threw an error!

BUT

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
difference...). 

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
work...

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: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20060804/17d08e9e/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: input.gif
Type: image/gif
Size: 2098 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20060804/17d08e9e/attachment-0001.gif>


More information about the postgis-users mailing list