Comparing version 1.0.2 to 1.0.3
@@ -189,3 +189,6 @@ /* | ||
return; | ||
} else if (nmea[0] !== "!AIVDM" && nmea[0] !== "!AIVDO") { //AIVDM = standard, AIVDO = own ship | ||
} else if (nmea[0] !== "!AIVDM" && // AIVDM: others | ||
nmea[0] !== "!AIVDO" && // AIVDO: own AIS | ||
nmea[0] !== "!BSVDM" && // BSVDM: from base stations | ||
nmea[0] !== "!ABVDM" ) { // ABVDM: from base stations | ||
this.error = "AisDecode: Invalid message prefix."; | ||
@@ -192,0 +195,0 @@ return; |
@@ -74,4 +74,4 @@ /* | ||
this.valid= this.nmea[6]; | ||
this.sog= parseFloat (this.nmea[7] || 0); | ||
this.cog = parseFloat (this.nmea[8] || 0); | ||
// nmea[7] is number of satellites | ||
// nmea[8] is HDOP | ||
this.alt = parseFloat (this.nmea[9] || 0); | ||
@@ -115,10 +115,15 @@ this.day = undefined; // only time in GPGGA | ||
} else { | ||
// $GPRMC 100106=10-jan-2006 053740.000=5h37m40s | ||
var d=this.day.substring (4,6); | ||
var m=this.day.substring (2,4)-1; //warning january=0 !!! | ||
var y='20' + this.day.substring (0,2); | ||
// sample GPRMC: | ||
// $GPRMC,013248.00,A,3733.10101,N,07618.46766,W,0.233,24.51,041219,10.98,W,A*3E | ||
// where: | ||
// 013248.00 is time hhmmss.ss utc | ||
// 041219 is date ddmmyy | ||
var d=this.day.substring (0,2); | ||
var m=this.day.substring (2,4); | ||
var y='20' + this.day.substring (4,6); | ||
var h=this.time.substring (0,2); | ||
var n=this.time.substring (2,4); | ||
var s=this.time.substring (4,6); | ||
this.date = Date.UTC (y,m,d,h,n,s); | ||
// note date.utc needs month as 0-11 not 1-12 | ||
this.date = Date.UTC (y,m-1,d,h,n,s); | ||
} | ||
@@ -125,0 +130,0 @@ |
@@ -44,3 +44,3 @@ /* | ||
var packet =util.format ("$GPRMC,%s.00,A,%s,%s,%s,%s,%s,%s,%s,,,A" | ||
, this.time, this.Dec2Min(msg.lat),lato, this.Dec2Min(msg.lon), lono, msg.sog, msg.cog, this.date); | ||
, this.time, this.Dec2Min(msg.lat,2),lato, this.Dec2Min(msg.lon,3), lono, msg.sog, msg.cog, this.date); | ||
@@ -65,10 +65,9 @@ var checksum = 0; // http://rietman.wordpress.com/2008/09/25/how-to-calculate-the-nmea-checksum/ | ||
// move from decimal notation to NMEA formating | ||
NmeaEncode.prototype.Dec2Min = function(cardinal){ | ||
// NMEA 4737.1024,N for 47°37'.1024 | ||
NmeaEncode.prototype.Dec2Min = function(cardinal,degpadded){ | ||
// NMEA 4737.1024,N for 47°37'.1024 (degrees padded to 2 digits) | ||
// NMEA 07620.7863,W for 76°20'.7863 W (degrees padded to 3 digits) | ||
if (cardinal<0) cardinal=cardinal*-1; | ||
var deg = parseInt (cardinal); | ||
var mindec = (cardinal-deg)*60; | ||
var min = parseInt (mindec); | ||
var secdec = mindec-min; | ||
var card=deg*100+min+secdec; | ||
var card=('00'+deg).slice(-degpadded) + ('0'+mindec.toFixed(4)).slice(-7); | ||
@@ -83,3 +82,6 @@ return (card); | ||
var time=stringDate.split (" "); | ||
this.date=time[0].substring (2,8); | ||
// yyyymmdd | ||
// 12345678 | ||
this.date=time[0].substring(6,8) + time[0].substring(4,6) + time[0].substring(2,4); | ||
// hhmmss | ||
this.time=time[1]; | ||
@@ -86,0 +88,0 @@ }; |
{ | ||
"name": "ggencoder", | ||
"description": "GEOGATE-geojson handles AIS/NMEA encoding/decoding for GEOgate GPS/AIS/GTS framework", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Fulup Ar Foll", |
@@ -42,4 +42,4 @@ GeoGate | ||
var encMsg = new AisEncode ({// class AB static info | ||
msgtype : 24, | ||
part : 2, | ||
aistype : 24, | ||
part : 1, | ||
mmsi : 271041815, | ||
@@ -60,3 +60,3 @@ cargo : 60, | ||
encMsg = new NmeaEncode ({ // standard class B Position report | ||
msgtype : 18, | ||
msgtype : 2, | ||
cog : 72.2, | ||
@@ -63,0 +63,0 @@ sog : 6.1000000000000005, |
@@ -62,6 +62,6 @@ /* | ||
nmea: '$GPRMC,182816.26,A,4916.45,N,10342.0309,E,00.00,000.00,210115,0,0,A67', | ||
lon: -123.18533333333335, | ||
lon: 103.700515, | ||
lat: 49.274166666666666, | ||
cog: 54.7, | ||
sog: 0.2 | ||
cog: 0, | ||
sog: 0 | ||
} | ||
@@ -68,0 +68,0 @@ |
115902
1883