Skip to content

Commit

Permalink
Update to handle new TIMs format.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Ferber committed Dec 7, 2017
1 parent ebf22ee commit 1298777
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 43 deletions.
20 changes: 10 additions & 10 deletions data/I_80_test_TIMS.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docker-test/test_in.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import sys

def print_bsm_data(d):
if d['metadata']['payloadType'] == 'us.dot.its.jpo.ode.model.OdeTIMPayload':
speed = d['metadata']['receivedDetails']['location']['speed']
lat = d['metadata']['receivedDetails']['location']['latitude']
lng = d['metadata']['receivedDetails']['location']['longitude']
if d['metadata']['payloadType'] == 'us.dot.its.jpo.ode.model.OdeTimPayload':
speed = d['metadata']['receivedMessageDetails']['locationData']['speed']
lat = d['metadata']['receivedMessageDetails']['locationData']['latitude']
lng = d['metadata']['receivedMessageDetails']['locationData']['longitude']

print('Producing TIMS with speed={}, position={}, {}'.format(speed, lat, lng), file=sys.stderr)

Expand Down
8 changes: 4 additions & 4 deletions docker-test/test_out.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import sys

def print_bsm_data(d):
if d['metadata']['payloadType'] == 'us.dot.its.jpo.ode.model.OdeTIMPayload':
speed = d['metadata']['receivedDetails']['location']['speed']
lat = d['metadata']['receivedDetails']['location']['latitude']
lng = d['metadata']['receivedDetails']['location']['longitude']
if d['metadata']['payloadType'] == 'us.dot.its.jpo.ode.model.OdeTimPayload':
speed = d['metadata']['receivedMessageDetails']['locationData']['speed']
lat = d['metadata']['receivedMessageDetails']['locationData']['latitude']
lng = d['metadata']['receivedMessageDetails']['locationData']['longitude']

print('Consuming TIMS with speed={}, position={}, {}'.format(speed, lat, lng))

Expand Down
174 changes: 173 additions & 1 deletion python/jsonify.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,165 @@
}
}

JSON_TIMS_2 = {
"payload": {
"dataType": "TravelerInformation",
"data": {
"MessageFrame": {
"value": {
"TravelerInformation": {
"msgCnt": 1,
"dataFrames": {
"TravelerDataFrame": {
"priority": 5,
"startYear": 2017,
"duratonTime": 1440,
"msgId": {
"roadSignID": {
"mutcdCode": {
"warning": ""
},
"viewAngle": 1111111111111111,
"position": {
"lat": 404725418,
"elevation": 4096,
"long": -1049700560
}
}
},
"sspMsgRights2": 1,
"regions": {
"GeographicalPath": {
"direction": 1111111111111111,
"laneWidth": 800,
"description": {
"path": {
"offset": {
"xy": {
"nodes": {
"NodeXY": [
{
"delta": {
"node-LatLon": {
"lat": 404735394,
"lon": -1049701440
}
}
},
{
"delta": {
"node-LatLon": {
"lat": 404732984,
"lon": -1049700032
}
}
},
{
"delta": {
"node-LatLon": {
"lat": 404730975,
"lon": -1049699856
}
}
},
{
"delta": {
"node-LatLon": {
"lat": 404718186,
"lon": -1049701616
}
}
},
{
"delta": {
"node-LatLon": {
"lat": 404716111,
"lon": -1049702321
}
}
},
{
"delta": {
"node-LatLon": {
"lat": 404715307,
"lon": -1049702937
}
}
}
]
}
}
}
}
},
"closedPath": {
"false": ""
},
"directionality": {
"both": ""
},
"anchor": {
"lat": 404725418,
"elevation": 4096,
"long": -1049700560
}
}
},
"sspLocationRights": 1,
"sspMsgRights1": 1,
"startTime": 401108,
"sspTimRights": 1,
"content": {
"advisory": {
"SEQUENCE": {
"item": {
"itis": 513
}
}
}
},
"frameType": {
"advisory": ""
}
}
},
"packetID": "000000000018099C39"
}
},
"messageId": 31
}
}
},
"metadata": {
"receivedMessageDetails": {
"locationData": {
"latitude": 40.4740885,
"speed": "0.10",
"elevation": 1484,
"heading": 193.6875,
"longitude": -104.9691905
},
"rxSource": "RSU"
},
"validSignature": False,
"recordGeneratedBy": "OBU",
"odeReceivedAt": "2017-12-06T23:15:59.596Z[UTC]",
"recordGeneratedAt": "2017-10-11T23:35:09.924Z[UTC]",
"logFileName": "rxMsg_1507764909_2001_3A470_3A41af_3A1_3A226_3Aadff_3Afe05_3A2561.csv",
"payloadType": "us.dot.its.jpo.ode.model.OdeTimPayload",
"schemaVersion": 3,
"serialId": {
"recordId": 2,
"bundleSize": 1,
"serialNumber": 0,
"bundleId": 6,
"streamId": "fef1b210-858b-4444-b0a9-72d4da9ad275"
},
"sanitized": False,
"recordType": "rxMsg"
}
}

from json import dumps, loads

import sys
Expand Down Expand Up @@ -616,6 +775,18 @@ def json3addSize(json_str_in):

return json_in

def json3toTIMS2(json_str_in):
json_in = loads(json_str_in)

json_tims_out = JSON_TIMS_2

json_tims_out['metadata']['receivedMessageDetails']['locationData']['latitude'] = json_in['payload']['data']['coreData']['position']['latitude']
json_tims_out['metadata']['receivedMessageDetails']['locationData']['longitude'] = json_in['payload']['data']['coreData']['position']['longitude']
json_tims_out['metadata']['receivedMessageDetails']['locationData']['speed'] = json_in['payload']['data']['coreData']['speed']

return json_tims_out


for line in sys.stdin:
if line[0] == '#':
continue
Expand All @@ -624,7 +795,8 @@ def json3addSize(json_str_in):
#json_ret = json2toJson3(line)
#json_ret = json1toJson3(line)
#json_ret = json3toTIMS(line)
json_ret = json3addSize(line)
#json_ret = json3addSize(line)
json_ret = json3toTIMS2(line)

if not json_ret:
# Invalid line.
Expand Down
10 changes: 5 additions & 5 deletions src/bsmfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,22 +537,22 @@ bool BSMHandler::process( const std::string& bsm_json ) {
size["width"] = 0;
}
}
} else if (payload_type_str == "us.dot.its.jpo.ode.model.OdeTIMPayload") {
if (!metadata.HasMember("receivedDetails")) {
} else if (payload_type_str == "us.dot.its.jpo.ode.model.OdeTimPayload") {
if (!metadata.HasMember("receivedMessageDetails")) {
result_ = ResultStatus::MISSING;

return false;
}

rapidjson::Value& received_details = metadata["receivedDetails"];
rapidjson::Value& received_details = metadata["receivedMessageDetails"];

if (!received_details.HasMember("location")) {
if (!received_details.HasMember("locationData")) {
result_ = ResultStatus::MISSING;

return false;
}

rapidjson::Value& location = received_details["location"];
rapidjson::Value& location = received_details["locationData"];

if (!location.HasMember("latitude") || !location.HasMember("longitude") || !location.HasMember("speed")) {
result_ = ResultStatus::MISSING;
Expand Down
Loading

0 comments on commit 1298777

Please sign in to comment.