all*_*Nit 7 iphone objective-c compass-geolocation
如何计算磁航向值以获得地理方向,即北,东北,东,东南,南,西南,西,西北?
由于磁航向仅返回度数值,并且我需要在不断更新的磁航向的基础上显示地理方向.
我怎样才能成功呢?
all*_*Nit 10
下面是我用来不断更新地理方向的代码.
CGFloat currentHeading = newHeading.magneticHeading;
NSString *strDirection = [[NSString alloc] init];
if(gradToRotate >23 && gradToRotate <= 67){
strDirection = @"NE";
} else if(gradToRotate >68 && gradToRotate <= 112){
strDirection = @"E";
} else if(gradToRotate >113 && gradToRotate <= 167){
strDirection = @"SE";
} else if(gradToRotate >168 && gradToRotate <= 202){
strDirection = @"S";
} else if(gradToRotate >203 && gradToRotate <= 247){
strDirection = @"SW";
} else if(gradToRotate >248 && gradToRotate <= 293){
strDirection = @"W";
} else if(gradToRotate >294 && gradToRotate <= 337){
strDirection = @"NW";
} else if(gradToRotate >=338 || gradToRotate <= 22){
strDirection = @"N";
}
Run Code Online (Sandbox Code Playgroud)
我的工作正常.如果需要任何修改,欢迎大师告诉我.
| 归档时间: |
|
| 查看次数: |
1716 次 |
| 最近记录: |