GeoFenceIsPointInPolygon Method
Determine if the coordinate is inside the polygon.
Namespace: CoordinateSharpAssembly: CoordinateSharp (in CoordinateSharp.dll) Version: 2.21.1.1
XMLNS for XAML: Not mapped to an xmlns.
public bool IsPointInPolygon(
Coordinate point
)
- point Coordinate
- Point to test
Booleanbool
Points sitting on the edge of a polygon may return true or false.
The following example shows how to determine if a coordinate is inside of a specified polygon.
List<GeoFence.Point> points = new List<GeoFence.Point>();
//Points specified manually to create a square in the USA.
//First and last points should be identical if creating a polygon boundary.
points.Add(new GeoFence.Point(31.65, -106.52));
points.Add(new GeoFence.Point(31.65, -84.02));
points.Add(new GeoFence.Point(42.03, -84.02));
points.Add(new GeoFence.Point(42.03, -106.52));
points.Add(new GeoFence.Point(31.65, -106.52));
GeoFence gf = new GeoFence(points);
Coordinate c = new Coordinate(36.67, -101.51);
//Determine if Coordinate is within polygon
Console.WriteLine(gf.IsPointInPolygon(c)); //True (coordinate is within the polygon)