Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 我怎样才能像这样格式化坐标?_Ios_Format_Coordinates_Degrees - Fatal编程技术网

Ios 我怎样才能像这样格式化坐标?

Ios 我怎样才能像这样格式化坐标?,ios,format,coordinates,degrees,Ios,Format,Coordinates,Degrees,我需要像这样格式化我的坐标: N 61° 14.5919' E 23° 28.1751' 61.145919 23.281751 现在我的坐标如下所示: N 61° 14.5919' E 23° 28.1751' 61.145919 23.281751 我的代码: - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation

我需要像这样格式化我的坐标:

N 61° 14.5919'
E 23° 28.1751'
61.145919
23.281751
现在我的坐标如下所示:

N 61° 14.5919'
E 23° 28.1751'
61.145919
23.281751
我的代码:

- (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation
{
    latitudeLabel.text = [NSString stringWithFormat:@"%f", newLocation.coordinate.latitude];
    longitudeLabel.text = [NSString stringWithFormat:@"%f", newLocation.coordinate.longitude];   
}

这个现有的问题似乎有关于如何最好地解决的建议,加上一个可以为您解决这个问题的库:

这个现有的问题似乎有关于如何最好地解决的建议,另外还有一个可以为您解决的库: 这并不是那么容易

在你的例子中,你得到了北纬61度和14.5919分,没有秒。(秒由分钟中的小数重新表示。)

你必须把分钟换算成摄氏度

61+14.5919/60将导致61.31983

<> P>你必须考虑纬度的负值和经度的负值。 您的示例碰巧有N和E坐标,这对正值很有效。但你不能认为这是理所当然的。如果你想得到一般性的解决方案,至少不会

关于纬度: 如果值>=0,则为N,否则为S。 可以trunc度的后逗号值并添加°。 然后取余数乘以60,作为分钟数,再加上th’

.145919*60=8.75514-这是本例中的分钟值。这应该会导致 N 61°8.75514'

由于您的问题与编程问题无关,而是与后面的数学相关,因此我让您从这里开始。

这并不是那么容易

在你的例子中,你得到了北纬61度和14.5919分,没有秒。(秒由分钟中的小数重新表示。)

你必须把分钟换算成摄氏度

61+14.5919/60将导致61.31983

<> P>你必须考虑纬度的负值和经度的负值。 您的示例碰巧有N和E坐标,这对正值很有效。但你不能认为这是理所当然的。如果你想得到一般性的解决方案,至少不会

关于纬度: 如果值>=0,则为N,否则为S。 可以trunc度的后逗号值并添加°。 然后取余数乘以60,作为分钟数,再加上th’

.145919*60=8.75514-这是本例中的分钟值。这应该会导致 N 61°8.75514'


由于您的问题与编程问题无关,而是与后面的数学相关,因此我将让您从这里开始。

请参考以下代码

int degreesLat = marker.position.latitude;
double decimalLat = fabs(marker.position.latitude-degreesLat);
int minutesLat = decimalLat*60;
double secondsLat = decimalLat*3600 - minutesLat*60;

请参考以下代码

int degreesLat = marker.position.latitude;
double decimalLat = fabs(marker.position.latitude-degreesLat);
int minutesLat = decimalLat*60;
double secondsLat = decimalLat*3600 - minutesLat*60;

[此][1]帖子可能会对您有所帮助。享受吧![1] :[这][1]帖子可能会对你有所帮助。享受吧![1]: