/// <summary>
/// 判断坐标点是否落在指定的多边形区域内
/// </summary>
/// <param name="point">指定的坐标点</param>
/// <param name="list">多变形区域的节点集合</param>
/// <returns>True 落在范围内 False 不在范围内</returns>
public bool IsWithIn(ESRI.ArcGIS.Client.Geometry.MapPoint point, List<ESRI.ArcGIS.Client.Geometry.MapPoint> list)
{
double x = point.X;
double y = point.Y;
int isum, icount, index;
double dLon1 = 0, dLon2 = 0, dLat1 = 0, dLat2 = 0, dLon;
if (list.Count < 3)
{
return false;
}
isum = 0;
icount = list.Count;
try
{
for (index = 0; index < icount - 1; index++)
{
if (index == icount - 1)
{
dLon1 = list[index].X;
dLat1 = list[index].Y;
dLon2 = list[0].X;
dLat2 = list[0].Y;
}
else
{
dLon1 = list[index].X;
dLat1 = list[index].Y;
dLon2 = list[index + 1].X;
dLat2 = list[index + 1].Y;
}
if (((y >= dLat1) && (y < dLat2)) || ((y >= dLat2) && (y < dLat1)))
{
if (Math.Abs(dLat1 - dLat2) > 0)
{
dLon = dLon1 - ((dLon1 - dLon2) * (dLat1 - y)) / (dLat1 - dLat2);
if (dLon < x)
isum++;
}
}
}
}
catch { }
if ((isum % 2) != 0)
{
return true;
}
else
{
return false;
}
}