Version: vs2012, geos3.5
First, download and compile
This kind of article comparison, no longer specific details, you can refer to http://blog.csdn.net/wangqinghao/article/details/8201319
My software save directory is d:/geos350/, after the successful compilation, a Geos_c_i.lib library will be generated in the D:/GEOS350/SRC directory.
After you create a new project in VS, you need to configure it in just three places:
First: Properties--Configuration Properties---C + +---general, add additional Include Directories D:/geos350/include
Second place: Properties--Configuration Properties---linker---general, additional library directory D:/GEOS350/SRC
Third place: Properties--Configuration Properties---linker--INPUT, additional dependencies: Geos_c_i.lib
Second, the test
Add header file First: #include "geos.h"
voidtest ();stringStrBOOLflag);intMainintargcChar*argv[]) {test (); System ("Pause"); return 1;}voidTest () {cout<<"The GEOS library version is:"<<GEOS_VERSION<<Endl; typedef coordinate PT; Geometryfactory Factory; Coordinatearraysequencefactory CSF; //Building the first rectangle P1coordinatesequence* CS1 = Csf.create (5,2);//Five 2-D points, and the third dimension Z is always 0Cs1->setat (PT (0,0),0); CS1->setat (PT (3,0),1); CS1->setat (PT (3,3),2); CS1->setat (PT (0,3),3); CS1->setat (PT (0,0),4);//equal to the first point, forming a closedlinearring* ring1 = factory.createlinearring (CS1);//Dot Formation linegeometry* P1 = Factory.createpolygon (ring1,null);//Line Composition Surfacecoordinatesequence* CS2 = Csf.create (5,2);//Building a quadrilateral P2Cs2->setat (PT (2,2),0); CS2->setat (PT (4,5),1); CS2->setat (PT (5,5),2); CS2->setat (PT (5,4),3); CS2->setat (PT (2,2),4); Linearring* Ring2 =factory.createlinearring (CS2); Geometry* P2 =(Factory.createpolygon (ring2,null)); Coordinatesequence*CS3 =NewCoordinatearraysequence ();//Build a triangle P3 intxoffset=4, yoffset=4, side=2; CS3-Add (PT (Xoffset, Yoffset)); CS3->add (PT (Xoffset, yoffset+side)); CS3->add (PT (Xoffset+side, yoffset+side)); CS3-Add (PT (Xoffset, Yoffset)); Linearring* Ring3 =factory.createlinearring (CS3); Geometry* P3 =(Factory.createpolygon (ring3,null)); BOOLFlag12=p1->intersects (P2); BOOLFlag13=p1->intersects (P3); BOOLFlag23=p2->intersects (P3); cout<<"Figure 1 and Figure 2:"<<str (FLAG12) <<Endl; cout<<"Figure 1 and Figure 3:"<<str (FLAG13) <<Endl; cout<<"Figure 2 and Figure 3:"<<str (flag23) <<Endl;}stringStrBOOLflag) { stringresult= (flag==true)?"intersect":"do not intersect"; returnresult;}
Results:
GEOS Library compilation and testing in Windows (VS2012)