Skip to content

Commit

Permalink
Merge pull request #93 from usdot-jpo-ode/message-forwarder-fixes
Browse files Browse the repository at this point in the history
Adding Null Checks to Message Forwarder
  • Loading branch information
John-Wiens authored Jun 13, 2024
2 parents 7fca82f + c460427 commit d98a161
Showing 1 changed file with 38 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,55 +54,58 @@ public String buildTopicName(int roadRegulatorID, int intersectionID, String mes
}

public void broadcastSpat(ProcessedSpat spat) {
Integer intersectionID = spat.getIntersectionId();
if (intersectionID == null) {
intersectionID = -1;
}
if(spat != null){
Integer intersectionID = spat.getIntersectionId();
if (intersectionID == null) {
intersectionID = -1;
}

Integer roadRegulatorID = spat.getRegion();
if (roadRegulatorID == null) {
roadRegulatorID = -1;
}
Integer roadRegulatorID = spat.getRegion();
if (roadRegulatorID == null) {
roadRegulatorID = -1;
}

if (intersectionID != -1) {
try {
broadcastMessage(buildTopicName(-1, intersectionID, "spat"), mapper.writeValueAsString(spat));
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if (intersectionID != -1) {
try {
broadcastMessage(buildTopicName(-1, intersectionID, "spat"), mapper.writeValueAsString(spat));
} catch (JsonProcessingException e) {
e.printStackTrace();
}

}

}
}

public void broadcastMap(ProcessedMap<LineString> map) {
Integer intersectionID = map.getProperties().getIntersectionId();
if (intersectionID == null) {
intersectionID = -1;
}
if(map != null){
Integer intersectionID = map.getProperties().getIntersectionId();
if (intersectionID == null) {
intersectionID = -1;
}

Integer roadRegulatorID = map.getProperties().getRegion();
if (roadRegulatorID == null) {
roadRegulatorID = -1;
}
Integer roadRegulatorID = map.getProperties().getRegion();
if (roadRegulatorID == null) {
roadRegulatorID = -1;
}

if (intersectionID != -1) {
try {
broadcastMessage(buildTopicName(-1, intersectionID, "map"), mapper.writeValueAsString(map));
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if (intersectionID != -1) {
try {
broadcastMessage(buildTopicName(-1, intersectionID, "map"), mapper.writeValueAsString(map));
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
}
}

public void broadcastBSM(BsmIntersectionIdKey key, OdeBsmData bsm) {
if (key.getIntersectionId() != -1) {
try {
broadcastMessage(buildTopicName(-1, key.getIntersectionId(), "bsm"), mapper.writeValueAsString(bsm));
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
if(bsm != null){
if (key.getIntersectionId() != -1) {
try {
broadcastMessage(buildTopicName(-1, key.getIntersectionId(), "bsm"), mapper.writeValueAsString(bsm));
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
}
}
Expand Down

0 comments on commit d98a161

Please sign in to comment.