/** * Helper Class for handling (Participant) Positions * $Id$ * $HeadURL$ * $Author$ * Created by Malte Diers, NLE, 2019-07-11 */ #include "participantposition.h" #include namespace HighLevelArchitecture { // // ParticipantPosition // rpr2::WorldLocationStruct ParticipantPosition::toWorldLocation() const { rpr2::WorldLocationStruct wl; LtsCoordTrans::lonLatAltToGeocentric(lon, lat, -z, wl.X, wl.Y, wl.Z); return wl; } QString ParticipantPosition::toString(bool mgrs) const { if (!mgrs) return QStringLiteral("lon: %1, lat: %2, z: %3").arg(lon).arg(lat).arg(z); const LtsCoordTrans::UtmCoordinate c1(LtsCoordTrans::UtmCoordinate::fromGeographic(lon, lat)); return QStringLiteral("MGRS: %1, Z: %2").arg(c1.mgrs()).arg(z); } bool ParticipantPosition::hasMoved(const ParticipantPosition &other) const { const LtsCoordTrans::UtmCoordinate c1(LtsCoordTrans::UtmCoordinate::fromGeographic(lon, lat)); const LtsCoordTrans::UtmCoordinate c2(LtsCoordTrans::UtmCoordinate::fromGeographic(other.lon, other.lat)); if (c1.zone != c2.zone) return true; if (std::abs(c1.x - c2.x) > 1) return true; if (std::abs(c1.y - c2.y) > 1) return true; return false; } bool ParticipantPosition::isNull() const { return (qFuzzyIsNull(lon) && qFuzzyIsNull(lat)); } ParticipantPosition::ParticipantPosition(const rpr2::WorldLocationStruct &wl) { LtsCoordTrans::geocentric2LonLatAlt(wl.X, wl.Y, wl.Z, lon, lat, z); z *= -1; } } // Namespace