Skip to content

Commit

Permalink
Merge pull request #3 from hexameron/master
Browse files Browse the repository at this point in the history
-ddmm.mmmm
  • Loading branch information
danielrichman committed Aug 12, 2015
2 parents e833c2c + 33f5cec commit 54a6061
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/UKHASExtractor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ static string convert_ddmmmm(const string &value)
if (right_val >= 60 || right_val < 0)
throw runtime_error("invalid right part (ddmm)");

if (value.find('-') != string::npos)
right_val *= -1;
double dd = left_val + (right_val / 60);

ostringstream os;
Expand Down
7 changes: 6 additions & 1 deletion tests/test_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,21 +363,26 @@ def test_multi_config(self):
"format":"dd.dddd"},
{"sensor":"stdtelem.coordinate","name":"lat_b",
"format":"ddmm.mm"},
{"sensor":"stdtelem.coordinate","name":"lat_a_neg",
"format":"ddmm.mm"},
{"sensor":"stdtelem.coordinate","name":"lat_b_neg",
"format":"ddmm.mm"},
{"name": "field_b"}
],
} ]
}

def test_ddmmmmmm(self):
self.extr.set_current_payload(self.ddmmmmmm_flight_doc)
string = "$$TESTING,0024.124583,5116.5271,whatever*14BA\n"
string = "$$TESTING,0024.124583,5116.5271,-0016.5271,-5116.5271,whatever*F390\n"
self.extr.push(string)
self.extr.check_status("start delim")
self.extr.check_upload(string)
self.extr.check_status("extracted")
self.extr.check_data({"_sentence": string, "_parsed": True,
"_protocol": "UKHAS", "payload": "TESTING",
"lat_a": "0024.124583", "lat_b": "51.27545",
"lat_a_neg": "-0.27545", "lat_b_neg": "-51.27545",
"field_b": "whatever" })

numeric_scale_flight_doc = {
Expand Down

0 comments on commit 54a6061

Please sign in to comment.