如果检测点的纬度/经度基于多边形经度、多边形、纬度

2023-09-03 13:12:12 作者:你我已不熟悉

我想检测,在服务器端只能使用C#,基于坐标纬度/经度是否是一个区域(多边形)内由纬度/经度基础点。我认为正确的方式做,这是光线投射,但也许已经有一个C#实现在那里,因为它是不平凡?

I'd like to detect, on the server side using C# only, whether a Latitude/Longitude based coordinate is within an area (polygon) made up of Latitude/Longitude based points. I believe the right way to do this is raycasting, but maybe there is already a C# implementation out there as it's not trivial?

另外,据我所知,SQL Server具有一定几何形状的功能,如 STIntersects 但为了使用,我需要在SQL Server 2008中运行,每个检查将涉及数据库连接,也就是不希望的。

Also, I understand that SQL Server has some geometry function such as STIntersects but in order to use that I need both SQL Server 2008 running and every check would involve a database connection which is undesirable.

推荐答案

由于球体是一个本地微分同胚于平面,您可以使用坐标平面,如该作品的任何算法this SO质疑。你只需要做的工作,翻译协调,如果你的多边形包含一个极点。根据你的使用情况,也许你可以拒绝那些投入。

Since a sphere is a locally diffeomorphic to the plane, you can use any algorithm that works on the cartesian plane, e.g. this SO question. You'll only have to do work translating coordinates if your polygon includes a pole. Depending on your use case, maybe you can reject those inputs.