Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ void TripleAssembler::generateTriplesFromNode(const Node& node, const SchemaType

const auto node_timestamp = getTimestampFromNode(node);

if (!node.getValue().has_value()) {
throw std::runtime_error("Node value is absent for node: " + node.getName());
}
triple_writer_.addElementDataToTriple(prefixes, data_values, node.getValue().value(),
node_timestamp, ntm_coord_value);
} catch (const std::exception& e) {
Expand Down Expand Up @@ -255,6 +258,15 @@ void TripleAssembler::generateTriplesFromCoordinates(
const DataMessage& message) {
{
try {
if (!valid_coordinates.has_value()) {
throw std::runtime_error("Coordinate pair is absent");
}
if (!valid_coordinates.value().latitude.getValue().has_value()) {
throw std::runtime_error("Latitude value is absent");
}
if (!valid_coordinates.value().longitude.getValue().has_value()) {
throw std::runtime_error("Longitude value is absent");
}
auto ntm_coord =
Helper::getCoordInNtm(valid_coordinates.value().latitude.getValue().value(),
valid_coordinates.value().longitude.getValue().value());
Expand Down
14 changes: 11 additions & 3 deletions cdsp/knowledge-layer/connector/utils/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ std::tuple<std::optional<std::tm>, std::optional<int>> Helper::parseISO8601ToTim
// Check for milliseconds in the format .sss
if (iso_string.find('.') != std::string::npos) {
std::string millisStr = iso_string.substr(iso_string.find('.') + 1, 3);
milliseconds = std::stoi(millisStr);
try {
milliseconds = std::stoi(millisStr);
} catch (const std::exception&) {
milliseconds = std::nullopt;
}
}

return {tm, milliseconds};
Expand Down Expand Up @@ -204,8 +208,12 @@ std::optional<NtmCoord> Helper::getCoordInNtm(const std::string& latitude,
}

Wgs84Coord coord_to_convert;
coord_to_convert.latitude = std::stod(latitude);
coord_to_convert.longitude = std::stod(longitude);
try {
coord_to_convert.latitude = std::stod(latitude);
coord_to_convert.longitude = std::stod(longitude);
} catch (const std::exception&) {
return std::nullopt;
}

return CoordinateTransform::ntmPoseFromWgs84(ZONE_ORIGIN, coord_to_convert);
}
Expand Down