MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / updateData

Method updateData

app/src/UI/Widgets/GPS.cpp:490–531  ·  view source on GitHub ↗

* @brief Updates GPS data from the dashboard model. */

Source from the content-addressed store, hash-verified

488 * @brief Updates GPS data from the dashboard model.
489 */
490void Widgets::GPS::updateData()
491{
492 if (!isEnabled())
493 return;
494
495 if (!VALIDATE_WIDGET(SerialStudio::DashboardGPS, m_index))
496 return;
497
498 const auto& series = UI::Dashboard::instance().gpsSeries(m_index);
499 if (series.latitudes.empty() || series.longitudes.empty() || series.altitudes.empty())
500 return;
501
502 const double alt = series.altitudes.back();
503 const double lat = series.latitudes.back();
504 const double lon = series.longitudes.back();
505
506 if (std::isnan(alt) && std::isnan(lat) && std::isnan(lon))
507 return;
508
509 if (DSP::almostEqual(lat, m_latitude) && DSP::almostEqual(lon, m_longitude)
510 && DSP::almostEqual(alt, m_altitude))
511 return;
512
513 if (!std::isnan(lat))
514 m_latitude = lat;
515
516 if (!std::isnan(lon))
517 m_longitude = lon;
518
519 if (!std::isnan(alt))
520 m_altitude = alt;
521
522 if (autoCenter())
523 center();
524
525 else {
526 update();
527 updateTiles();
528 }
529
530 Q_EMIT updated();
531}
532
533//--------------------------------------------------------------------------------------------------
534// Tile management

Callers

nothing calls this directly

Calls 5

VALIDATE_WIDGETFunction · 0.85
isnanFunction · 0.85
almostEqualFunction · 0.85
updateFunction · 0.85
emptyMethod · 0.80

Tested by

no test coverage detected