@@ -45,8 +45,8 @@ const gprmc = new XRegExp(
45
45
(?<type> \\w{3}) \\,
46
46
(?<time> \\d{6}[.]\\d{3}) \\,
47
47
(?<gpsStatus> \\w{1}) \\,
48
- (?<latitude> \\d{0, 4}[.]\\d{0, 4}\\,[NS]) \\,
49
- (?<longitude> \\d{0, 5}[.]\\d{0, 4}\\,[WE]) \\,
48
+ (?<latitude> \\d{4}[.]\\d{4}\\,[NS]) \\,
49
+ (?<longitude> \\d{5}[.]\\d{4}\\,[WE]) \\,
50
50
(?<speed> \\d{1,3}[.]\\d{1,3}) \\,
51
51
(?<track> \\d{1,3}[.]\\d{1,3}) \\,
52
52
(?<date> \\d{6}) \\,
@@ -74,10 +74,8 @@ export function isValid(data) {
74
74
export function latToDmm ( data ) {
75
75
const decimal = Math . abs ( data )
76
76
const degree = Math . floor ( decimal )
77
- const minutes = Math . floor ( decimal * 60 ) % 60
78
- const seconds = Math . round ( 100 * ( ( decimal * 3600 ) % 60 ) ) / 100
79
77
const dd = pad ( degree , 2 , "0" )
80
- const mm = ( minutes + ( seconds / 60 ) ) . toFixed ( 4 )
78
+ const mm = pad ( ( ( decimal - degree ) * 60.0 ) . toFixed ( 4 ) , 7 , "0" )
81
79
const sign = data < 0 ? "S" : "N"
82
80
return `${ dd } ${ mm } ,${ sign } `
83
81
}
@@ -91,10 +89,8 @@ export function latToDmm(data) {
91
89
export function lngToDmm ( data ) {
92
90
const decimal = Math . abs ( data )
93
91
const degree = Math . floor ( decimal )
94
- const minutes = Math . floor ( decimal * 60 ) % 60
95
- const seconds = Math . round ( 100 * ( ( decimal * 3600 ) % 60 ) ) / 100
96
92
const dd = pad ( degree , 3 , "0" )
97
- const mm = ( minutes + ( seconds / 60 ) ) . toFixed ( 4 )
93
+ const mm = pad ( ( ( decimal - degree ) * 60.0 ) . toFixed ( 4 ) , 7 , "0" )
98
94
const sign = data < 0 ? "W" : "E"
99
95
return `${ dd } ${ mm } ,${ sign } `
100
96
}
@@ -200,14 +196,14 @@ export function randomData() {
200
196
const now = moment ( )
201
197
const time = now . format ( "HHmmss.SSS" )
202
198
const gpsStatus = "A"
203
- const lat = chance . floating ( { min : - 90 , max : 90 , fixed : 2 } )
204
- const lng = chance . floating ( { min : - 180 , max : 180 , fixed : 2 } )
199
+ const lat = chance . floating ( { min : - 90 , max : 90 } )
200
+ const lng = chance . floating ( { min : - 180 , max : 180 } )
205
201
const latitude = latToDmm ( lat )
206
202
const longitude = lngToDmm ( lng )
207
- const speed = chance . floating ( { min : 0 , max : 300 , fixed : 2 } )
208
- const track = chance . floating ( { min : 0 , max : 40 , fixed : 2 } )
203
+ const speed = chance . floating ( { min : 0 , max : 300 } ) . toFixed ( 2 )
204
+ const track = chance . floating ( { min : 0 , max : 40 } ) . toFixed ( 2 )
209
205
const date = now . format ( "DDMMYY" )
210
- const mvValue = chance . floating ( { min : 0 , max : 40 , fixed : 1 } )
206
+ const mvValue = chance . floating ( { min : 0 , max : 40 } ) . toFixed ( 1 )
211
207
const mvSign = chance . string ( { pool : "WE" , length : 1 } )
212
208
const mv = `${ mvValue } ,${ mvSign } `
213
209
const magneticVariation = chance . pick ( [ mv , "," ] )
0 commit comments