[geos-devel] intersect/intersection() problem under Win

Martin Davis mbdavis at VividSolutions.com
Thu Oct 16 11:54:30 EDT 2003


This is definitely a robustness issue (related to the "numerical precision" you mention, but more complex).  JTS 1.3 exhibits the same problem.  I'm happy to say that the forthcoming JTS 1.4 contains some bug fixes which seem to solve this problem.  These will need to be rolled into GEOS sometime... (but first - FIXING LEAKS!)

Strange that Linux doesn't exhibit the same problem.  What hardware are you running on?  These kind of problems will work better on machines with higher precision floating point - could that be the difference?    Otherwise I can't imagine what aspect of the Linux box would make a difference (I'd like to attribute it to a higher quality OS, but realistically that's unlikely to have any effect...)

Martin Davis, Senior Technical Architect
Vivid Solutions Inc.
Suite #1A-2328 Government Street   Victoria, B.C.   V8T 5G5
Phone: (250) 385 6040    Fax: (250) 385 6046



> -----Original Message-----
> From: Christian Pschierer [mailto:pschirus at gmx.net]
> Sent: Thursday, October 16, 2003 8:29 AM
> To: GEOS Development List
> Subject: [geos-devel] intersect/intersection() problem under Win
> 
> 
> Hi all,
> 
> we are currently writing a little application which checks 
> geometries for
> true intersections and returns the area of the intersection.
> 
> ...
> if( ( g1->intersects( g2 ) == TRUE ) &&
>     ( g1->touches( g2 ) == FALSE ) ){
>    intersectionArea = g1->intersection( g2 )->getArea();
> ...
> 
> On Linux this works pretty well. On Windows XP (Visual Studio 6.0) and
> Irix (MIPSpro Compilers: Version 7.3.1.3m) we found 2 
> polygons which cause
> an Exception in intersection().
> 
> We traced the error back to the file
>  geos/source/graph/DirectedEdgeStar.cpp:178
> 
> if (state==LINKING_TO_OUTGOING) {
>    if (firstOut==NULL)
>       throw new TopologyException("no outgoing dirEdge
>       found",&(getCoordinate()));
> ...
> 
> Any ideas what causes this problem and how to solve it? Our 
> guess is, that
> some kind of numerical precision problem leads to this 
> behavior, as Linux
> computes an area of 0 for in this case.
> 
> Below you can find a modified SimpleWKTTester-program which 
> can reproduce
> this error on Windows and Irix.
> 
> 
> Greetings
> Christian Pschierer
> 
> 
> P.S.:
>  The TopologyException-Class is missing the toString()-Method. 
> Can someone with write-Access to the CVS-Repository please copy this
> method from source/util/GEOSException.cpp to
> source/geom/TopologyException.cpp? Thank you.
> 
> 
> WKTIn:
> POLYGON(( -79.63495899324135500000 43.68317101967772900000,
>  -79.63535258791171100000 43.68308676161363700000,
>  -79.63709417370184000000 43.68469600959869600000,
>  -79.63582188599052400000 43.68383905676894600000,
>  -79.63495899324135500000 43.68317101967772900000))
> POLYGON(( -79.63544261367904700000 43.68354543050776300000,
>  -79.63538454138728200000 43.68359271151414400000,
>  -79.63528343774432000000 43.68352100382917100000,
>  -79.63533917745682800000 43.68346535191968600000,
>  -79.63544261367904700000 43.68354543050776300000))
> 
> 
> 
> Main.cpp:
> 
> #include <iostream>
> #include <fstream>
> 
> #include "headers/io.h"
> 
> using namespace std;
> using namespace geos;
> 
> int main(int argc, char** argv)
> {
> 	 
> 	try {
> 		ifstream in("WKTIn");
> 		string instr;
> 		WKTReader *r = new WKTReader(new GeometryFactory(new
> PrecisionModel(),10));
> 		Geometry *g1;
> 		Geometry *g2;
> 		Geometry *intersectg1g2;
> 		bool intersect;
> 		bool touch;
> 
> 		getline(in,instr);
> 		g1=r->read(instr);
> 		getline(in,instr);
> 		g2=r->read(instr);
> 
> 		intersect=g1->intersects(g2);
> 		if(intersect)
> 			cout << "g1 and g2 intersect!" << endl;
> 		else
> 			cout << "g1 and g2 do not intersect!" << endl;
> 
> 		touch=g1->touches(g2);
> 		if(touch)
> 			cout << "g1 and g2 touch!" << endl;
> 		else
> 			cout << "g1 and g2 do not touch!" << endl;
> 
> 		///////////////////////////////////////////
> 		// This leads to an exception under WinXP and Irix
> 
> 		cout << "Before intersection" << endl;
> 		intersectg1g2=g1->intersection( g2 );
> 		cout << "After intersection" << endl;
> 		
> 		///////////////////////////////////////////
> 
> 		if( intersectg1g2 ) {
> 			cout << "The intersection has an area of " <<
> intersectg1g2->getArea() << endl;
> 		}
> 	}
> 	catch (GEOSException *ge) {
> 		cout << "Caught GEOSException!" << endl;
> 		cout << ge->toString() << endl;
> 	}
> 	catch (TopologyException *te) {
> 		cout << "Caught TopologyException!" << endl;
> 	}
> 
> 	return 0;
> }
> 
> 
> 
> 
> 
> _______________________________________________
> geos-devel mailing list
> geos-devel at geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel
> 



More information about the geos-devel mailing list