[geos-devel] Simple example (20 lines of code) crashes, but why ?

Yücel Ahi y.ahi at web.de
Fri May 18 10:03:13 EDT 2007


my very simple sample code (below) crashes when i call isValid(). Can
anybody reproduce the problem or know what the problem might be ?

Thanks in advance.


#include "geos/geom/Coordinate.h"
#include "geos/geom/CoordinateArraySequence.h"
#include "geos/geom/LineString.h"
#include "geos/geom/LinearRing.h"
#include "geos/geom/GeometryFactory.h"

using namespace geos::geom;

int main(int argc, char *argv[])
	CoordinateArraySequence* coords = new CoordinateArraySequence();

	//Simple rectangle
	coords->add(Coordinate(-1, 1));
	coords->add(Coordinate( 1, 1));
	coords->add(Coordinate( 1,-1));
	coords->add(Coordinate(-1, 1));

	GeometryFactory factory;
	LinearRing* linearRing = factory.createLinearRing(coords);
	bool yes = linearRing->isValid(); // <---- Crashes here !!!

	return 0;

More information about the geos-devel mailing list