Math 检测坐标是否位于经纬度边界框内
数学从来都不是我的强项,我正在努力完成一项任务 我需要确定一组经度和纬度坐标是否落在一个框内,其中给出了最大/最小经度和最大/最小纬度 任何帮助都将不胜感激 **编辑** 我使用的是GPS坐标,所以最小经度可能大于最大经度。i、 e如果框超过日期行。Math 检测坐标是否位于经纬度边界框内,math,coordinates,Math,Coordinates,数学从来都不是我的强项,我正在努力完成一项任务 我需要确定一组经度和纬度坐标是否落在一个框内,其中给出了最大/最小经度和最大/最小纬度 任何帮助都将不胜感激 **编辑** 我使用的是GPS坐标,所以最小经度可能大于最大经度。i、 e如果框超过日期行。box=左、右、上、下 box = left, right, top, bottom point = x, y if (x >= left && x <= right && y >= bottom
box=左、右、上、下
box = left, right, top, bottom
point = x, y
if (x >= left && x <= right && y >= bottom && y <= top) {
return true
} else {
return false
}
点=x,y
如果(x>=左&&x=下&&y给定minlat
,maxlat
,minlong
和maxlong
(即方框的四个角)然后,只需确定您的lat
是否介于minlat
和maxlat
之间,以及您的long
是否介于minlong
和maxlong
之间
如果箱子横跨180°
通过增加(或减去)相同的偏移量(注意标记)移动所有经度,或者沿着经度将箱子分成两部分180°
,并分别测试两部分。如果(纬度>=给定。最小纬度和纬度=给定。最小经度和经度
if( latitude>= given.minimumLatitude and lat <= given.maximumLatitude )
{
if( longitude >= given.minimumLongitude and longitude <= given.maximumLongitude )
{
return true;
}
}
return false;