[geos-devel] a crash in createPolygon

=?gb2312?B?s/bDu9ei0uIgwPHEzg==?= kurama_xp at hotmail.com
Sat Mar 13 23:42:38 EST 2010


Skipped content of type multipart/alternative-------------- next part --------------
#include "geos.h"

bool Contain(double *PH_x, double *PH_y, size_t PH_Num)
{
	GeometryFactory GF;

	geos::geom::Polygon *PG1;

	std::vector<Geometry*> holes;

	CoordinateArraySequence *PH=new CoordinateArraySequence();

	for(size_t i=0; i<PH_Num; i++)
	{
		PH->add(Coordinate(PH_x[i], PH_y[i], 0));
	}

	PH->add(Coordinate(PH_x[0], PH_y[0], 0));

//	std::cout<<PH->getSize()<<std::endl;

//	std::cout<<PH->toString()<<std::endl;

	LinearRing *HoleRing=GF.createLinearRing(*PH);

	std::cout<<HoleRing->getNumPoints()<<std::endl;	
	 
	std::cout<<HoleRing->isSimple()<<std::endl;
	 
	std::cout<<HoleRing->isClosed()<<std::endl;

	PG1=GF.createPolygon(*HoleRing, holes);

	GF.destroyGeometry(HoleRing);

	if(PH) 
	{
		delete PH;

		PH=NULL;
	}

	GF.destroyGeometry(PG1);

	return true;
};

void main()
{	
	double x[3];
	x[0]=0;
	x[1]=1;
	x[2]=1;

	double y[3];
	y[0]=0;
	y[1]=0;
	y[2]=1;

	Contain(x, y, 3);
};


More information about the geos-devel mailing list