Skip to content

Commit

Permalink
feat: added navStatus and posAcc fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Codeninja-Kjetil committed Jun 25, 2019
1 parent 2cc9d19 commit b187f13
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ais2geojson.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ int main(int argc, char *argv[]) {

char
config_smi = 1,
config_nav_status = 1,
config_pos_acc = 1,
config_cog = 1,
config_trueheading = 1,
config_sog = 1;
Expand Down Expand Up @@ -59,6 +61,12 @@ int main(int argc, char *argv[]) {
if(config_trueheading && pos->trueheading >= 0 && pos->trueheading < 360) {
printf("\"trueHeading\":%d,", pos->trueheading);
}
if(config_nav_status && pos->nav_status >= 0) {
printf("\"navStatus\":%d,", pos->nav_status);
}
if(config_pos_acc && pos->pos_acc >= 0) {
printf("\"posAcc\":%d,", pos->pos_acc);
}
if(config_smi && pos->smi >= 0) printf("\"smi\":%d,", pos->smi);
// always print ts so we don't need to check if we need comma or not
if(pos->ts == 0) printf("\"ts\":false");
Expand Down
11 changes: 11 additions & 0 deletions aismsg_pos.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ int buf2pos(char* buf, aismsg_pos *pos) {
ais.msgid = (unsigned char) get_6bit( &ais.six_state, 6);
pos->msgid = ais.msgid;
pos->smi = -1;
pos->nav_status = -1;

switch( ais.msgid ) {
case 1: {
Expand All @@ -59,6 +60,8 @@ int buf2pos(char* buf, aismsg_pos *pos) {
pos->sog = sog2float(msg_1.sog);
pos->trueheading = msg_1.true;
pos->smi = regional2smi(msg_1.regional);
pos->nav_status = msg_1.nav_status;
pos->pos_acc = msg_1.pos_acc;
} else return 1;
break;
}
Expand All @@ -72,6 +75,8 @@ int buf2pos(char* buf, aismsg_pos *pos) {
pos->sog = sog2float(msg_2.sog);
pos->trueheading = msg_2.true;
pos->smi = regional2smi(msg_2.regional);
pos->nav_status = msg_2.nav_status;
pos->pos_acc = msg_2.pos_acc;
} else return 2;
break;
}
Expand All @@ -85,6 +90,8 @@ int buf2pos(char* buf, aismsg_pos *pos) {
pos->sog = sog2float(msg_3.sog);
pos->trueheading = msg_3.true;
pos->smi = regional2smi(msg_3.regional);
pos->nav_status = msg_3.nav_status;
pos->pos_acc = msg_3.pos_acc;
} else return 3;
break;
}
Expand All @@ -94,6 +101,7 @@ int buf2pos(char* buf, aismsg_pos *pos) {
{
pos->userid = msg_4.userid;
pos2ddd( msg_4.latitude, msg_4.longitude, &pos->lat_dd, &pos->long_ddd );
pos->pos_acc = msg_4.pos_acc;
} else return 4;
break;
}
Expand All @@ -106,6 +114,7 @@ int buf2pos(char* buf, aismsg_pos *pos) {
pos->cog = cog2float(msg_9.cog);
pos->sog = sog2float(msg_9.sog);
pos->smi = regional2smi(msg_9.regional);
pos->pos_acc = msg_9.pos_acc;
} else return 0;
break;
}
Expand All @@ -118,6 +127,7 @@ int buf2pos(char* buf, aismsg_pos *pos) {
pos->cog = cog2float(msg_18.cog);
pos->sog = sog2float(msg_18.sog);
pos->trueheading = msg_18.true;
pos->pos_acc = msg_18.pos_acc;
// [ITU.1371] says message has no regional / smi
} else return 18;
break;
Expand All @@ -131,6 +141,7 @@ int buf2pos(char* buf, aismsg_pos *pos) {
pos->cog = cog2float(msg_19.cog);
pos->sog = sog2float(msg_19.sog);
pos->trueheading = msg_19.true;
pos->pos_acc = msg_19.pos_acc;
// [ITU.1371] says message has not regional / smi
} else return 19;
break;
Expand Down
2 changes: 2 additions & 0 deletions aismsg_pos.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ struct aismsg_pos {
float sog;
int trueheading;
int smi; // 2 bits special-man-indicator
int nav_status;
int pos_acc;

long userid;
char* ts;
Expand Down

0 comments on commit b187f13

Please sign in to comment.