javascript 纬度经度格式错误 DDDMM.MMMM 2832.3396N
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18442158/
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
Latitude Longitude in wrong format DDDMM.MMMM 2832.3396N
提问by Ishmeet
I have a gps module that gives me latitude in longitude in a weird format.
我有一个 gps 模块,它以一种奇怪的格式为我提供经度纬度。
DDDMM.MMMM
As written on user manual, Degrees*100 + Minutes.
如用户手册上所写,度数*100 + 分钟。
As far as I know, It is degrees minutes seconds, and seconds is between 0-59, above than this will increment the minute. But this is giving minutes in decimal places. Does this means 1/1000th of a minute?
据我所知,它是度分秒,秒在 0-59 之间,高于此将增加分钟。但这是以小数位给出分钟数。这是否意味着一分钟的 1/1000?
eg. 07717.3644 E
077 --> degrees
17 --> minutes
3644 --> ?
E --> Direction
Also how will I convert it to decimal, I am using the formula
另外我将如何将其转换为十进制,我正在使用公式
decimal = degrees + minutes/60 + seconds/3600.
回答by Gangadhar
To convert this to the decimal format, we start by keeping the DD portion and simply divide the MM.MMM by 60 to firm the MMM portion of the decimal format.
要将其转换为十进制格式,我们首先保留 DD 部分,然后简单地将 MM.MMM 除以 60 以固定十进制格式的 MMM 部分。
43. (48.225/60), -79.(59.074/60)
43.(0.80375), -79.(0.98456)
43.80375, -79.98456
In your case
在你的情况下
eg. 07717.3644 E is the DDDMM.MMMM format
077 --> degrees
17 --> minutes
.3644 --> minutes equals to sec/60
decimal = degrees + minutes/60
decimal = 77 + (17.3644 / 60)
decimal = 77.28941
回答by John Bode
1 minute = 60 seconds, so .3644 minutes = .3644 * 60 = 21.86 seconds.
1 分钟 = 60 秒,所以 .3644 分钟 = .3644 * 60 = 21.86 秒。
回答by Clifford
The value is not a number but a string of degrees and minutes concatenated. You need to be careful because it is likely that latitude values only have two degree digits (i.e. DDMM.MMMM), so if you use string handling to separate the values, you's have to account for that . However both long and lat can be handled numerically as follows:
该值不是数字,而是一串连接的度数和分钟数。您需要小心,因为纬度值可能只有两个度数(即 DDMM.MMMM),因此如果您使用字符串处理来分隔值,则必须考虑到这一点。但是 long 和 lat 都可以用数字处理如下:
double GpsEncodingToDegrees( char* gpsencoding )
{
double a = strtod( gpsencoding, 0 ) ;
double d = (int)a / 100 ;
a -= d * 100 ;
return d + (a / 60) ;
}
You might also pass the hemisphere character E/W or N/S to this function and use it to determine an appropriate +/- sign if required.
您还可以将半球字符 E/W 或 N/S 传递给此函数,并在需要时使用它来确定适当的 +/- 符号。
回答by Antonio
Simple implementation in Python:
Python 中的简单实现:
latitude = <ddmm.mmmm>
longitude = <dddmm.mmmmm>
# Ricava i gradi della latitudine e longitudine
lat_degree = int(latitude / 100);
lng_degree = int(longitude / 100);
# Ricava i minuti della latitudine e longitudine
lat_mm_mmmm = latitude % 100
lng_mm_mmmmm = longitude % 100
# Converte il formato di rappresentazione
converted_latitude = lat_degree + (lat_mm_mmmm / 60)
converted_longitude = lng_degree + (lng_mm_mmmmm / 60)
print converted_latitude, converted_longitude
Replace latitude and logitude.
替换纬度和对数。
回答by KARTHIKEYAN.A
Follow the algorithm to convert the same.
按照算法进行转换。
var t = "7523.7983" // (DDMM.MMMM)
var g = "03412.9873" //(DDDMM.MMMM)
function lat(t){
return (Number(t.slice(0,2)) + (Number(t.slice(2,9))/60))
}
function lng(g) {
return (Number(g.slice(0,3)) + (Number(g.slice(3,10))/60))
}
console.log(lat(t))
console.log(lng(g))