用于确定收集经度/纬度坐标的最小边界矩形的算法 [英] Algorithm for determining minimum bounding rectangle for collection of latitude/longitude coordinates
问题描述
可以假定一个平坦的地球,因为坐标不会相隔太远。伪代码是可以的,但是如果有人在Objective-C中做了这个,那会更好。我试图做的是根据地图上显示的点数设置地图的缩放级别。
解决方案这将为您的左上角点
找到最小的纬度/经度,并为您的右下角找到最大的纬度/经度。
double minLat = 900;
double minLon = 900;
double maxLat = -900;
double maxLon = -900;
foreach(latloncollection中的Point point)
{
minLat = Math.min(minLat,point.lat);
minLon = Math.min(minLon,point.lon);
maxLat = Math.max(maxLat,point.lat);
maxLon = Math.max(maxLon,point.lon);
}
Is there an algorithm to determine the minimum bounding rectangle around a set of latitude/longitude coordinates?
It is OK to assume a flat earth since the coordinates will not be too far apart. Pseudocode is OK, but if someone has done this in Objective-C, that would be even better. What I am trying to do is set the zoom level of a map based on the number of points that will be displayed on the map.
This will find the smallest latitude/longitude for your top left point and the largest latitude/longitude for your bottom right point.
double minLat = 900;
double minLon = 900;
double maxLat = -900;
double maxLon = -900;
foreach(Point point in latloncollection )
{
minLat = Math.min( minLat, point.lat );
minLon = Math.min( minLon, point.lon );
maxLat = Math.max( maxLat, point.lat );
maxLon = Math.max( maxLon, point.lon );
}
这篇关于用于确定收集经度/纬度坐标的最小边界矩形的算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!