Latitude Longitude in wrong format DDDMM.MMMM 2832

2020-05-21 08:01发布

I have a gps module that gives me latitude in longitude in a weird format.

DDDMM.MMMM

As written on user manual, Degrees*100 + Minutes.

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?

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.

5条回答
萌系小妹纸
2楼-- · 2020-05-21 08:37

1 minute = 60 seconds, so .3644 minutes = .3644 * 60 = 21.86 seconds.

查看更多
▲ chillily
3楼-- · 2020-05-21 08:37

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:

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.

查看更多
祖国的老花朵
4楼-- · 2020-05-21 08:51

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.

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

See this Link Would help you

查看更多
姐就是有狂的资本
5楼-- · 2020-05-21 08:56

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))  

查看更多
别忘想泡老子
6楼-- · 2020-05-21 08:57

Simple implementation in 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.

查看更多
登录 后发表回答