Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
* Adding comments to GPS trace
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Berger <christian.berger@gu.se>
  • Loading branch information
chrberger committed Dec 4, 2018
1 parent ea554f7 commit cb3caf3
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/rec-metadataToJSON.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,49 @@ int32_t main(int32_t argc, char **argv) {
}
}
}
std::cout << " ] ," << std::endl
<< " \"gpsCommentsTrace\": [ " << std::endl;
// Export opendlv.system.LogMessage with associated GPS coordinates.
{
if (!envelopesWithOpendlvProxyGeodeticWgs84Reading.empty()) {
uint32_t counter{0};
std::vector<cluon::data::Envelope>::iterator closestGPS;
std::array<double, 2> position = {0, 0};

for (auto e : envelopesWithOpendlvSystemLogMessage) {
if ( (e.dataType() == opendlv::system::LogMessage::ID()) &&
(e.senderStamp() == 999) ) {
if (!envelopesWithOpendlvProxyGeodeticWgs84Reading.empty()) {
if (0 == counter) {
closestGPS = envelopesWithOpendlvProxyGeodeticWgs84Reading.begin();
}
while (closestGPS != envelopesWithOpendlvProxyGeodeticWgs84Reading.end()) {
auto delta = cluon::time::deltaInMicroseconds(e.sampleTimeStamp(), (*closestGPS).sampleTimeStamp());
if ( (delta > 0) && (delta < static_cast<int64_t>(250*1000)) ) {
cluon::data::Envelope env = *closestGPS;
opendlv::proxy::GeodeticWgs84Reading pos = cluon::extractMessage<opendlv::proxy::GeodeticWgs84Reading>(std::move(env));
position[0] = pos.latitude();
position[1] = pos.longitude();
break;
}

closestGPS++;
}
}
time_t logMessageSampleTime = e.sampleTimeStamp().seconds();
::ctime_r(&logMessageSampleTime, dateTimeBuffer);
std::string strLogMessageSampleTime(dateTimeBuffer);
strLogMessageSampleTime = strLogMessageSampleTime.substr(0, strLogMessageSampleTime.size()-1);
strLogMessageSampleTime = stringtoolbox::trim(strLogMessageSampleTime);

opendlv::system::LogMessage logMessage = cluon::extractMessage<opendlv::system::LogMessage>(std::move(e));

std::cout << ((counter > 0)? "," : "") << "{ \"timestamp\": \"" << strLogMessageSampleTime << "\", \"comment\":\"" << logMessage.description() << "\", \"position\":{" << "\"latitude\":" << std::setprecision(10) << position[0] << std::setprecision(6) << ",\"longitude\":" << std::setprecision(10) << position[1] << std::setprecision(6)<< "} }" << std::endl;
counter++;
}
}
}
}
std::cout << " ] ," << std::endl
<< " \"gpsTrace\": [ " << std::endl;
// Export opendlv.proxy.GeodeticWgs84Reading.
Expand Down
20 changes: 20 additions & 0 deletions webapp/views/details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,26 @@ function exportSelectedMessages() {
});
}
}
{{#each gpsCommentsTrace}}
var geoJSON = `{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [{{position.longitude}},{{position.latitude}}]
},
"properties": {
"name": "{{comment}}"
}
}
`;
var marker = maptalks.GeoJSON.toGeometry(geoJSON).addTo(g_map.getLayer('trace'));
marker.setInfoWindow({
'title': '{{timestamp}}',
'content' : '{{comment}}',
'autoCloseOn' : 'click'
});
{{/each}}
</script>

</body>
Expand Down

0 comments on commit cb3caf3

Please sign in to comment.