#include "ogrsf_frmts.h"

#include "gdal_priv.h"

#include <geos_c.h>


/************************************************************************/
/*                                main()                                */
/************************************************************************/

int main( int nArgc,  char* papszArgv[] )
{


	printf ("Testing point in polygon\n"); 
              

	OGRPoint pnt1;
	printf ("\tSet point\n");
                     
	double x = 5;
	pnt1.setX (x); 

	double y = 5.0;
	pnt1.setY (y);

	printf ("\tCompleted set point\n");

	OGRGeometry *tmp_pt1 = pnt1.clone();

	OGRLinearRing  oRing;
	OGRPolygon oPoly;

        printf ("\tSet polygon\n");
	oRing.addPoint( 10.0, 10.0 );
	oRing.addPoint( 10.0, 30.0 );
	oRing.addPoint( 30.0, 30.0 );
	oRing.addPoint( 30.0, 10.0 );
	oRing.addPoint( 10.0, 10.0 );

	oPoly.addRing( &oRing );

        printf ("\tCompleted set polygon\n");

	OGRGeometry *tmp_poly = oPoly.clone();

        printf ("Check point within polygon\n");

	if ( tmp_pt1->Within ( tmp_poly ) )
	{
	   printf ("\tPoint is in the polygon\n");
	}
 	else
 	{
	  printf ("\tPoint is not in the polygon\n");
	}

}
