Test with dotspatial.topology, even if there is a Nettopologysuite class library to test:
1Polygon Inputgeometry =NULL;2LineString Analysisgeoemtry =NULL;3 Private voidButton1_Click (Objectsender, EventArgs e)4 {5 varcoords =Newcoordinate[7];6 //Shell coordinates7 varCoordscheck =Newcoordinate[7];8 Double[] Xs =New Double[] { -,260, the, -, -, the, the, the, -, -, -, -, -,260 };9 Double[] Ys =New Double[] { $,260, the, Max, the, About, $,260 };Ten for(vari =0; I < xs.length/2; i++) One { A varx = Xs[i *2]; - vary = xs[i *2+1]; -Coords[i] =Newcoordinate (x, y); theCoordscheck[i] =Newcoordinate (x, y); - } - //coordscheck[19] = new coordinate (Coords[0]. X, Coords[0]. Y); - //coords[19] = new coordinate (Coords[0]. X, Coords[0]. Y); + //Shell Rings - varRing =Newlinearring (coords); + varGF =Newgeometryfactory (); A varRingcheck =GF. Createlinearring (Coordscheck); at //Hole coordinates - varCoordsholecheck =Newcoordinate[4]; - varCoordshole =Newcoordinate[4]; - for(vari =0; I < ys.length/2; i++) - { - varx = Ys[i *2]; in vary = ys[i *2+1]; -Coordshole[i] =Newcoordinate (x, y); toCoordsholecheck[i] =Newcoordinate (x, y); + } - //Hole linearring Arrays the varHole =Newlinearring (coordshole); * varHoles =Newilinearring[1]; $ varHolecheck =GF. Createlinearring (Coordsholecheck);Panax Notoginseng varHolescheck =Newilinearring[1]; -holes[0] =hole; theholescheck[0] =Holecheck; +Polygon pg =NewPolygon (ring, holes);// A varPolygoncheck =GF. Createpolygon (Ringcheck, holescheck); the varAreacheck =Polygoncheck.area; + varArea =pg. area; - // $Inputgeometry =pg; $ - Double[] Lines =New Double[] { -, -, the, the }; - varCOORDS1 =Newcoordinate[2]; the varRnd1 =NewRandom (); - varCoordscheck1 =Newcoordinate[2];Wuyi for(vari =0; I < lines.length/2; i++) the { - varx = Lines[i *2]; Wu vary = lines[i *2+1]; -Coords1[i] =Newcoordinate (x, y); AboutCoordscheck1[i] =Newcoordinate (x, y); $ } - - varGF1 =Newgeometryfactory (); - varLscheck =GF1. Createlinestring (COORDSCHECK1); ALineString ls =NewLineString (COORDS1); +Analysisgeoemtry =ls; theIntersectionoutput =analysisgeoemtry.intersection (inputgeometry); - This. Invalidate (); $ } theIgeometry Intersectionoutput =NULL; the Private voidForm1_paint (Objectsender, PaintEventArgs e) the { theGraphics GC = This. CreateGraphics (); - if(Inputgeometry! =NULL) in { theGraphicshelper.drawpolygon (GC, Inputgeometry,NewSolidBrush (color.red),NewPen (NewSolidBrush (Color.lightyellow)),false); the } About if(Analysisgeoemtry! =NULL) the { theGraphicshelper.drawlinestring (GC, Analysisgeoemtry,NewPen (NewSolidBrush (Color.Blue)); the } + if(Intersectionoutput! =NULL) - { the if(Intersectionoutput isLineString)Bayi { theLineString LSR = Intersectionoutput asLineString; thePen MP =NewPen (NewSolidBrush (Color.yellow)); -Mp. Width =2; - graphicshelper.drawlinestring (GC, LSR, MP); the } the if(Intersectionoutput ismultilinestring) the { theMultilinestring MLSR = Intersectionoutput asmultilinestring; - for(inti =0; I < MLSR. Numgeometries; i++) the { the if(MLSR. Geometries[i] isLineString) the {94LineString LSR = MLSR. Geometries[i] asLineString; thePen MP =NewPen (NewSolidBrush (Color.yellow)); theMp. Width =2; the graphicshelper.drawlinestring (GC, LSR, MP);98 } About } - }101 }102 GC. Dispose ();103}
Nettopologysuite Use (1)