ios 以度/弧度转换纬度/经度?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10140029/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 17:50:26  来源:igfitidea点击:

Convert Latitude / Longitude in Degree/Radians?

iphoneiosxcodemapkittype-conversion

提问by Umair_uas

How can i convert Latitude and longitude in degree/radians? Do you guys any formula or any idea? I want to show it on MapKit. Thanks.....

如何以度/弧度转换纬度和经度?你们有什么公式或任何想法吗?我想在 MapKit 上展示它。谢谢.....

回答by George Johnston

Since Latitude and Longitude are measured in degrees, you can use the following formula to convert to radians, and back to degrees:

由于纬度和经度以度为单位测量,因此您可以使用以下公式转换为弧度,然后再转换为度:

Radians = Degrees * PI / 180

and on the inverse,

相反,

Degrees = Radians * 180 / PI

回答by Nelson

If you look at earth like a sphere, latitude and longitude are already given in units of degrees. Longitude is expressed as -180 degrees (-pi radians) to 180 degrees (pi radians) with 0 degrees centered at the prime meridian. Latitude is expressed as -90 degrees (-pi/2 radians) to 90 degrees (pi/2 radians) with respect to the equator. This is already a spherical coordinate system (depending on the caveats I give below) with earth's radius approximately 6371 km.

如果你把地球看成一个球体,纬度和经度已经以度为单位给出了。经度表示为 -180 度(-pi 弧度)到 180 度(pi 弧度),0 度以本初子午线为中心。纬度表示为相对于赤道的 -90 度(-pi/2 弧度)到 90 度(pi/2 弧度)。这已经是一个球坐标系(取决于我在下面给出的注意事项),地球半径约为 6371 公里。

So just convert by multiplying by pi/180 as you would for convert degrees to radians in any normal sense. If you want to use those radians for doing something specific like calculating distances between two lat/lons then you should look at some pre-existing sources.

因此,只需乘以 pi/180 进行转换,就像在任何正常意义上将度数转换为弧度一样。如果你想用这些弧度来做一些特定的事情,比如计算两个纬度/经度之间的距离,那么你应该查看一些预先存在的来源

Similar questions have been asked before, i.e. Convert Lat-Lon to Cartesian Coordinates.

之前也有人问过类似的问题,即Convert Lat-Lon to Cartesian Coordinates

Generally speaking, the 'correct' answer for a lot of conversion quesitons depends on what error is acceptable in your answer (can it be off 1 mile for distances of 20 miles, etc.) and the model of the world is appropriate in your problem domain. The world is better approximated by an ellipsoid (squashed sphere) than a sphere, but it is easier to perform the calculations assuming earth is a sphere and the error introduced can be minimal. Especially if your program is just looking for 'rough' answers that won't be used for, say, engineering projects.

一般来说,许多转换问题的“正确”答案取决于您的答案中可接受的错误(对于 20 英里的距离是否可以偏离 1 英里等)以及世界模型是否适合您的问题领域。用椭球体(压扁的球体)比用球体更能近似世界,但假设地球是一个球体并且引入的误差最小,则更容易执行计算。特别是如果您的程序只是在寻找不会用于工程项目的“粗略”答案。

It is likely that the lat-lons you have are given in a coordinate system called WGS-84 which is what most hardware GPS units use, which assumes an ellipsoid model.

您所拥有的经纬度很可能是在称为 WGS-84 的坐标系中给出的,这是大多数硬件 GPS 单元使用的坐标系,它假定一个椭球模型。

Note that I had a lot more sources, but I guess I have low reputation so I can only post two links. I would suggest reading on wikipedia about WGS-84, earth's radius, spherical coordinates, prime meridian, and equator for some visual references.

请注意,我有更多的来源,但我想我的声誉很低,所以我只能发布两个链接。我建议在维基百科上阅读关于 WGS-84、地球半径、球坐标、本初子午线和赤道的一些视觉参考。