查找最小/最大纬度和经度 [英] Find Minimum/Maximum latitude and Longitude
问题描述
我的问题是如何从当前位置找到特定区域 (500米) 的最小和最大纬度和经度.
My Question is how can i find minimum and maximum latitude and longitude of specific area (500 meter) from current location.
就我而言,例如,我需要获取 X 和 Y CLLocation
(纬度和经度)从 500
面积米
看到我的图片(很抱歉,这张照片可能不好用)
In my case, Such like i need to get X and Y CLLocation
(latitude and longitude) from 500
meter of area
See my image (sorry for this may be bad drawing )
我还必须尝试使用Google谷歌搜索功能,并且获得类似
I also have to tried to googling and i got link such like
但是我不知道它如何实现.
But i don't know how it implement in my case.
请帮助我解决这个问题.
Pleas help me in this issue.
注意:我不想使用
CLLocationDistance distance = [currentLocation distanceFromLocation:newLocation];
,因为它对我的情况没有帮助.
NOTE : I do not want to use
CLLocationDistance distance = [currentLocation distanceFromLocation:newLocation];
because it is not helpful in my case so..
推荐答案
If you don't need a really precise value, then use the approximation that 1 degree is 111 km. Based on this, you need to add and remove 0.0025 degrees to the current coordinates to get corners of the area you are looking for.
rectanglesidelengthmeters = 500
degreedeltalat = 0.001 * (rectanglesidelengthmeters / 2.0) * cos(current.lon)
degreedeltalon = 0.001 * (rectanglesidelengthmeters / 2.0) * cos(current.lat)
minlat = current.lat - degreedeltalat
maxlat = current.lat + degreedeltalat
minlon = current.lon - degreedeltalon
maxlon = current.lon + degreedeltalon
您可能需要稍微校正一下结果,以使纬度值保持在-90 .. 90范围内,经度值保持在-180 .. 180范围内,但我认为CLClocation也会为您处理.
You may need to correct the result a little for staying in the -90 .. 90 range for latitude and -180 .. 180 range for longitude values but I think CLClocation will handle that for you too.
这篇关于查找最小/最大纬度和经度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!