[英]Finding a point on a straight line with DbGeography.Intersect()
我目前正在学习 C# 中的 DbGeography 并尝试使用一些功能。
我一直在尝试确定Intersects()
方法是否会为位于直线上的点(表示为 LineString DbGeography
对象)返回 true,如果该点位于起点和终点之间。
所以,我的问题是:是否可以信任[myPoint].Intersects([myLine])
方法来告诉我 myPoint 是否位于 myLine 上?
是的,您可以使用Intersects
方法来确定一个点是否位于一条线上,只要该点位于该线的边界框内即可。
例如:
DbGeography myPoint = DbGeography.PointFromText("POINT(10 10)", 4326);
DbGeography myLine = DbGeography.LineFromText("LINESTRING(0 0, 20 20)", 4326);
bool myPointIntersectsWithmyLine = myPoint.Intersects(myLine);
变量myPointIntersectsWithmyLine
在这里应该为真,因为myPoint
位于myline
对象上。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.