如果给定左上角和右下角的经纬度,如何确定特定的经纬度是否在矩形内部?
理想情况下,我将寻找类似于以下内容的东西:
bool IsWithinArea(float topLeftLat,float topLeftLong,
float bottomRightLat,float bottomRightLong,float testLat,float testLong)
更新
唯一的问题是,从经纬度创建的矩形可能来自旋转的地图,因此右下角不总是大于左上角...
如果给定左上角和右下角的经纬度,如何确定特定的经纬度是否在矩形内部?
理想情况下,我将寻找类似于以下内容的东西:
bool IsWithinArea(float topLeftLat,float topLeftLong,
float bottomRightLat,float bottomRightLong,float testLat,float testLong)
更新
唯一的问题是,从经纬度创建的矩形可能来自旋转的地图,因此右下角不总是大于左上角...
return new Rect(topLeftLat, topLeftLong, bottomRightLat - topLeftLat, bottomRightLong - topLeftLong)
.Contains(testLat, testLong);
我不确定自己是否想得太简单了。
这句话与IT技术无关。bool IsWithinArea(float topLeftLat, float topLeftLong, float bottomRightLat, float bottomRightLong, float testLat, float testLong)
{
return (testLat >= topLeftLat && testLat <= bottomRightLat && testLong >= topLeftLong && testLong <= bottomRightLong);
}
public bool IsWithinArea(float topLeftLat,float topLeftLong,
float bottomRightLat,float bottomRightLong,float testLat,float testLong) {
return (testLat >= topLeftLat && testLat <= bottomRightLat && testLong >= topLeftLong && testLong <= bottomRightLong);
}