Point on Polygon (Longitude/Latitude) in .NET [duplicate]
Possible Duplicate:
Point in Poly开发者_C百科gon aka hit test
I need some help for my problem ;): I've got a polygon definied with 3 or more longitude/latitude points. Now I've got another longitude/latitude point and I need to check if this point is in the polygon area or not.
I need this function in .NET. Can anyone help me?
Thank you very much for your help.
Here is one answer: http://alienryderflex.com/polygon/
You could also use Microsoft's Geometry classes. Create two geometries (one point, one polygon), then do an Intersection of them. If there is an intersection
http://msdn.microsoft.com/en-us/library/system.windows.media.combinedgeometry.geometrycombinemode.aspx
If these methods take too long, you could first wrap the polygon in a bounding box and test if the point is within the min/max lat/long of the box
Note: If your polygon crosses international dateline you may need to add additional code up front before these tests (i.e. add 360 degrees to longitude of polygon's vertices and to point if the longitude is negative so the algorithms work).
精彩评论