AE determines if the point is within the face

Source: Internet
Author: User
Tags ipoint

1         /// <summary>2         ///gets the polygon based on the ID of the polygon feature and determines whether the point is within the polygon3         /// </summary>4         /// <param name= "point" >to judge the point, the beginning of the Ray</param>5         /// <param name= "ID" >ID of the polygon</param>6         /// <param name= "Pfeaturelayer" >layer where polygon features are located</param>7         /// <returns></returns>8         Private BOOLPointisinpolygon (IPoint Point,intID, Ifeaturelayer pfeaturelayer)9         {TenIfeatureclass Pfeatureclass =Pfeaturelayer.featureclass; OneIpolygon Ppolygon = (pfeatureclass.getfeature (ID)). Shape asIpolygon; A             //comparison to the maximum minimum xy value of a polygon -Ienvelope Penvelope =NewEnvelopeclass (); -Penvelope =Ppolygon.envelope; the             if(Point. x<penvelope.xmin| | Point. x>penvelope.xmax| | Point. y<penvelope.ymin| | Point. Y>Penvelope.ymax) -                 return false; -             //If, in this range, the left is the ray, determine the number of intersections according to the topology of the line and Polygon -             Try { +IPoint Topoint =NewPointclass (); -Topoint.putcoords (Getxminvalue (Ppolygon)-20.00000000, point. Y); +Ipolyline PLine =NewPolylineclass ();//define Ray APline.topoint =Topoint; atPline.frompoint =Point ; -  -Itopologicaloperator Ptopo = Ppolygon asItopologicaloperator; -Igeometrycollection Pgeocol = Ptopo.intersect ((igeometry) pLine, esrigeometrydimension.esrigeometry0dimension) asigeometrycollection; -Ipointcollection Ppointcol = Pgeocol asipointcollection; -                 if((ppointcol.pointcount)%2==0) in                 { -                     return false; to                 } +                 Else -                 { the                     return true; *                 } $                 Panax Notoginseng             } -             Catch(Exception ee) the             { + MessageBox.Show (EE. Message); A                 return false; the             } +         } -         /// <summary> $         ///gets the X minimum value of the polygon $         /// </summary> -         /// <param name= "Ppolygon" ></param> -         /// <returns></returns> the         Private DoubleGetxminvalue (Ipolygon ppolygon) -         {WuyiIpointcollection ppointcollection = Ppolygon asipointcollection; the             intn =Ppointcollection.pointcount; -             Double[] Coordx =New Double[n]; Wu              for(inti =0; I < n; i++) -             { AboutIPoint point =Ppointcollection.get_point (i); $Coordx[i] =Point . X; -             } - System.Array.Sort (COORDX); -             returncoordx[0]; A}

AE Determines whether the point is inside the polygon

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.