大佬教程收集整理的这篇文章主要介绍了Objective C / iPhone比较2个CLLocations / GPS坐标,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有’newLOCATIOn’作为你所在的位置,我认为问题是我需要能够分离newLOCATIOn的long和lat数据.
到目前为止,我试过这个:
NSString *latitudeVar = [[NSString alloc] initWithFormat:@"%g°",newLOCATIOn.coordinate.latitude]; NSString *longitudeVar = [[NSString alloc] initWithFormat:@"%g°",newLOCATIOn.coordinate.longitude];
GPS位置列表的示例:
LOCATIOn:(CLLOCATIOn*)newLOCATIOn; CLLOCATIOnCoordinate2D bonusOne; bonusOne.latitude = 37.331689; bonusOne.longitude = -122.030731;
然后
if (latitudeVar == bonusOne.latitude && longitudeVar == bonusOne.longitudE) { UIAlertView *alert = [[UIAlertView alloc] initWithtitle:@"infinite loop firday" message:@"infloop" delegate:nil cancelButtontitle:@"STinky" otherButtontitles:nil ]; [alert show]; [alert release]; }
这会产生一个错误’无效操作数到二进制==有strut NSString和CLLOCATIOndegrees’
有什么想法吗?
if(fabs(latitude1 - latitude2) <= 0.000001) ...
另一种选择可以是通过计算距离来检查人与所需位置的距离.这也可以考虑到GPS的坐标不完全正确的事实,但即使在良好的条件下也可能相差10米:
CLLOCATIOn *loc1 = [[CLLOCATIOn alloc] initWithLatitude:lat1 longitude:lon1]; double distance = [loc1 getDistanceFrom:position2]; if(distance <= 10) ...
克劳斯
以上是大佬教程为你收集整理的Objective C / iPhone比较2个CLLocations / GPS坐标全部内容,希望文章能够帮你解决Objective C / iPhone比较2个CLLocations / GPS坐标所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。