用于确定收集经度/纬度坐标的最小边界矩形的算法 [英] Algorithm for determining minimum bounding rectangle for collection of latitude/longitude coordinates

查看:234
本文介绍了用于确定收集经度/纬度坐标的最小边界矩形的算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种算法来确定一组纬度/经度坐标的最小边界矩形?



可以假定一个平坦的地球,因为坐标不会相隔太远。伪代码是可以的,但是如果有人在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆