0
我有一个确定的点是多边形内或不什么是平等的SQL函数或StoredProcedure的我的C#方法
C#方法是这样的这个C#方法:
/// <summary>
/// Determine that a point in inside a polygon or not
/// </summary>
/// <param name="points">Points of Polygon</param>
/// <param name="point">Test Point</param>
/// <returns></returns>
Public bool IsInside(List<PointF> points,PointF point)
{
int i, j,n=points.Count;
bool c = false;
for (i = 0, j = n - 1; i < n; j = i++)
{
if (((points[i].Y > point.Y) != (points[j].Y > point.Y)) &&
(point.X <
(points[j].X - points[i].X)*(point.Y - points[i].Y)/(points[j].Y - points[i].Y) + points[i].X))
c = !c;
}
return c;
}
我如何转换这到SQL函数或StoredProcedure?
@ a_horse_with_no_name Microsoft SQL SERVER 2016 – Ali7091
创建两个几何实例并使用['STContains'](https://msdn.microsoft.com/en-gb/library/bb933904.aspx) –
一个想法:您可以通过列表的点作为xml数据,并将x和y参数指向您的函数或存储过程。在存储过程或函数内部使用openxml将xml数据加载到表中(在函数中,您需要表变量)。然后运行select查询,并将if条件的条件放在where子句中。 –