如何计算iOS中的地理边界框? [英] How to calculate geography bounding box in iOS?

查看:111
本文介绍了如何计算iOS中的地理边界框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在iOS中进行地理边界框计算。
它可以是aprox。

输入参数:

当前位置(例如:41.145495,-73.994901)

半径(以米为单位):(例如:2000)

要求输出:



MinLong :(例如:41.9995495)

MinLat :(例如: (例如:-74.004901)



MaxLong:(例如:41.0005495)

MaxLat:(例如:-73.004901) p>

要求:
无网络电话



Mapkit / CoreLocation似乎没有提供这种类型的东西?



我可以使用的任何其他地理软件开发工具包?



Thanks

解决方案

我认为您可以使用标准的MapKit函数: MKCoordinateRegionMakeWithDistance ,这将返回a MKCoordinateRegion ,它实际上只是一个中心点(lat,lon),以及纬度和纵向方向上的跨度(度)。

 

code> CLLocationCoordinate2D centerCoord = CLLocationCoordinate2DMake(41.145495,-73.994901);
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(centerCoord,2000,2000);

double latMin = region.center.latitude - .5 * startRegion.span.latitudeDelta;
double latMax = region.center.latitude + .5 * startRegion.span.latitudeDelta;
double lonMin = region.center.longitude - .5 * startRegion.span.longitudeDelta;
double lonMax = region.center.longitude + .5 * startRegion.span.longitudeDelta;顺便说一句:这只是代表小跨度的经度,按照一对夫妇的顺序公里。至引用Apple


latitudeDelta

用于跨度的北 - 南距离(以度数衡量)的量。与纵向距离不同,纬度因纬度而异,一度纬度约为111公里(69英里)。

longitudeDelta

用于跨度的东西距离(以度为单位)的量。经度范围跨越的公里数根据当前的纬度而变化。例如,一个经度跨越赤道约111公里(69英里)的距离,但在两极缩小到0公里。


I'd like to make a Geographic Bounding box Calculation in iOS. It can be aprox.

Input Parameters:

Current Location (Example: 41.145495, −73.994901)

Radius In Meters: (Example: 2000)

Required Output:

MinLong: (Example: 41.9995495)

MinLat: (Example: −74.004901)

MaxLong: (Example: 41.0005495)

MaxLat: (Example: −73.004901)

Requirement: No Network Call

Any Ideas? Mapkit / CoreLocation does not seem to offer this type of thing?

Any other Geographic SDK that i could use?

Thanks

解决方案

I think you can use standard MapKit functions: MKCoordinateRegionMakeWithDistance, this will return a MKCoordinateRegion, which is really just a center point (lat, lon) and the spans in the latitudal and longitudal direction in degrees. Add/subtract half of the span from the latitude and longitude respectively and you have the values you're looking for.

CLLocationCoordinate2D centerCoord = CLLocationCoordinate2DMake(41.145495, −73.994901);
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(centerCoord, 2000, 2000);

double latMin = region.center.latitude - .5 * startRegion.span.latitudeDelta;
double latMax = region.center.latitude + .5 * startRegion.span.latitudeDelta;
double lonMin = region.center.longitude - .5 * startRegion.span.longitudeDelta;
double lonMax = region.center.longitude + .5 * startRegion.span.longitudeDelta;

By the way: this is only representative for the longitude for small spans, in the order of a couple of kilometers. To quote Apple:

latitudeDelta
The amount of north-to-south distance (measured in degrees) to use for the span. Unlike longitudinal distances, which vary based on the latitude, one degree of latitude is approximately 111 kilometers (69 miles) at all times.

longitudeDelta
The amount of east-to-west distance (measured in degrees) to use for the span. The number of kilometers spanned by a longitude range varies based on the current latitude. For example, one degree of longitude spans a distance of approximately 111 kilometers (69 miles) at the equator but shrinks to 0 kilometers at the poles.

这篇关于如何计算iOS中的地理边界框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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