Apply clang-format to Lts/Common and DTC/enum headers
- Formatted all CodeGen module files (9 files) - Formatted LtsAppDescriptor module files - Formatted LtsAppManager/AppChooser files - Applied clang-format to all DTC and enum headers across modules - Removed coordTransTests from CommonUnitTestsPlaceholder (moved to tests/) Cosmetic changes only, no functional modifications. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
848 files changed
+89305
-100020
No files matched your search
Executable → Regular
+118
-150
@@ -1,230 +1,198 @@
|
||||
|
||||
|
||||
|
||||
#include "elevation_unit_test.h"
|
||||
|
||||
#include <ElevationMap/elevation_map_manager.h>
|
||||
#include <LtsCoordTrans/lts_coord_trans.h>
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <QtTest/QTest>
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
|
||||
Q_DECLARE_METATYPE(LtsUtils::QPoint3D);
|
||||
Q_DECLARE_METATYPE(LtsElevation::LineOfSight);
|
||||
|
||||
#include <iostream>
|
||||
|
||||
static const int s_id{4711};
|
||||
static LtsElevation::LtsElevationManager *s_eleMgr{nullptr};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static const int s_id{4711};
|
||||
static LtsElevation::LtsElevationManager* s_eleMgr{nullptr};
|
||||
|
||||
class MyLtsElevationManagerBootstrap : public LtsElevation::LtsElevationManager
|
||||
{
|
||||
using BaseClass = LtsElevation::LtsElevationManager;
|
||||
|
||||
public:
|
||||
static LtsElevationManager *createInstanceUnitTest(int id, const QStringList &filePaths_rough_to_fine)
|
||||
{
|
||||
return BaseClass::createInstanceUnitTest(id, filePaths_rough_to_fine);
|
||||
}
|
||||
using BaseClass = LtsElevation::LtsElevationManager;
|
||||
|
||||
public:
|
||||
static LtsElevationManager* createInstanceUnitTest(int id, const QStringList& filePaths_rough_to_fine)
|
||||
{
|
||||
return BaseClass::createInstanceUnitTest(id, filePaths_rough_to_fine);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
UnitTestElevation::UnitTestElevation()
|
||||
: m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("UnitTestElevation"))
|
||||
{}
|
||||
|
||||
: m_logger(NGL::NGLLoggerBootstrap::getNGLRootLogger().getNGLLogger("UnitTestElevation"))
|
||||
{
|
||||
}
|
||||
|
||||
void UnitTestElevation::initTestCase()
|
||||
{
|
||||
|
||||
|
||||
QString filePath(QStringLiteral("/usr/share/arcgis/resources/elevation/Altmark_dt1.tif"));
|
||||
QString filePath(QStringLiteral("/usr/share/arcgis/resources/elevation/Altmark_dt1.tif"));
|
||||
|
||||
s_eleMgr = MyLtsElevationManagerBootstrap::createInstanceUnitTest(s_id, {filePath});
|
||||
s_eleMgr = MyLtsElevationManagerBootstrap::createInstanceUnitTest(s_id, {filePath});
|
||||
|
||||
const bool bIsValid = s_eleMgr->isValid();
|
||||
std::cerr << "myBootstrapMgr->isValid() 1 = " << bIsValid << std::endl;
|
||||
|
||||
|
||||
{
|
||||
s_eleMgr->waitForInitialization();
|
||||
const bool bIsValid = s_eleMgr->isValid();
|
||||
std::cerr << "myBootstrapMgr->isValid() 2 = " << bIsValid << std::endl;
|
||||
}
|
||||
std::cerr << "myBootstrapMgr->isValid() 1 = " << bIsValid << std::endl;
|
||||
|
||||
{
|
||||
s_eleMgr->waitForInitialization();
|
||||
const bool bIsValid = s_eleMgr->isValid();
|
||||
std::cerr << "myBootstrapMgr->isValid() 2 = " << bIsValid << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void UnitTestElevation::init()
|
||||
{
|
||||
QVERIFY2(s_eleMgr , "static LtsElevationManager does not exist");
|
||||
QVERIFY2(s_eleMgr, "static LtsElevationManager does not exist");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void UnitTestElevation::test_elevation_data()
|
||||
{
|
||||
QTest::addColumn<QPointF>("lonLat");
|
||||
QTest::addColumn<double>("elevationRef");
|
||||
QTest::addColumn<QPointF>("lonLat");
|
||||
QTest::addColumn<double>("elevationRef");
|
||||
|
||||
|
||||
QTest::newRow("elevation 1 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 70000 10000")).geographic() << 75.0;
|
||||
QTest::newRow("elevation 2 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 72000 13000")).geographic() << 80.0;
|
||||
QTest::newRow("elevation 1 ")
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 70000 10000")).geographic() << 75.0;
|
||||
QTest::newRow("elevation 2 ")
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 72000 13000")).geographic() << 80.0;
|
||||
|
||||
|
||||
|
||||
|
||||
QTest::newRow("elevation 3 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 76925 18625")).geographic() << 92.0;
|
||||
QTest::newRow("elevation 3 ")
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 76925 18625")).geographic() << 92.0;
|
||||
}
|
||||
|
||||
void UnitTestElevation::test_elevation()
|
||||
{
|
||||
QFETCH(QPointF, lonLat);
|
||||
QFETCH(double, elevationRef);
|
||||
QFETCH(QPointF, lonLat);
|
||||
QFETCH(double, elevationRef);
|
||||
|
||||
double elevation = s_eleMgr->elevation(lonLat.x(), lonLat.y());
|
||||
double elevation = s_eleMgr->elevation(lonLat.x(), lonLat.y());
|
||||
|
||||
QVERIFY2(qFuzzyCompare(elevationRef, elevation), " got wrong elevation result");
|
||||
QVERIFY2(qFuzzyCompare(elevationRef, elevation), " got wrong elevation result");
|
||||
}
|
||||
|
||||
void UnitTestElevation::test_elevation_isCovered()
|
||||
{
|
||||
const QPointF &lonLat1 = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 70000 10000")).geographic();
|
||||
const QPointF &lonLat2 = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 60000 10000")).geographic();
|
||||
const QPointF& lonLat1 = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 70000 10000")).geographic();
|
||||
const QPointF& lonLat2 = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U MD 60000 10000")).geographic();
|
||||
|
||||
const double defaultElevationValue = -123;
|
||||
{
|
||||
bool bIsCovered = false;
|
||||
s_eleMgr->elevation(lonLat1.x(), lonLat1.y(), defaultElevationValue, &bIsCovered);
|
||||
QVERIFY2(bIsCovered, " error on bIsCovered");
|
||||
}
|
||||
{
|
||||
bool bIsCovered = true;
|
||||
s_eleMgr->elevation(lonLat2.x(), lonLat2.y(), defaultElevationValue, &bIsCovered);
|
||||
QVERIFY2(!bIsCovered, " error on bIsCovered");
|
||||
}
|
||||
const double defaultElevationValue = -123;
|
||||
{
|
||||
bool bIsCovered = false;
|
||||
s_eleMgr->elevation(lonLat1.x(), lonLat1.y(), defaultElevationValue, &bIsCovered);
|
||||
QVERIFY2(bIsCovered, " error on bIsCovered");
|
||||
}
|
||||
{
|
||||
bool bIsCovered = true;
|
||||
s_eleMgr->elevation(lonLat2.x(), lonLat2.y(), defaultElevationValue, &bIsCovered);
|
||||
QVERIFY2(!bIsCovered, " error on bIsCovered");
|
||||
}
|
||||
}
|
||||
|
||||
void UnitTestElevation::test_elevation_defaultValue()
|
||||
{
|
||||
const QPointF &lonLat = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 60000 10000")).geographic();
|
||||
const QPointF& lonLat = LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 60000 10000")).geographic();
|
||||
|
||||
double elevation = s_eleMgr->elevation(lonLat.x(), lonLat.y());
|
||||
QVERIFY2(qFuzzyCompare(elevation, std::numeric_limits<double>::min()), " error on defaultValue");
|
||||
double elevation = s_eleMgr->elevation(lonLat.x(), lonLat.y());
|
||||
QVERIFY2(qFuzzyCompare(elevation, std::numeric_limits<double>::min()), " error on defaultValue");
|
||||
|
||||
{
|
||||
const double defaultValue = 100;
|
||||
elevation = s_eleMgr->elevation(lonLat.x(), lonLat.y(), defaultValue);
|
||||
QVERIFY2(qFuzzyCompare(elevation, defaultValue), " error on defaultValue");
|
||||
}
|
||||
{
|
||||
const double defaultValue = 100;
|
||||
elevation = s_eleMgr->elevation(lonLat.x(), lonLat.y(), defaultValue);
|
||||
QVERIFY2(qFuzzyCompare(elevation, defaultValue), " error on defaultValue");
|
||||
}
|
||||
|
||||
{
|
||||
const double defaultValue = std::numeric_limits<double>::max();
|
||||
elevation = s_eleMgr->elevation(lonLat.x(), lonLat.y(), defaultValue);
|
||||
QVERIFY2(qFuzzyCompare(elevation, defaultValue), " error on defaultValue");
|
||||
}
|
||||
{
|
||||
const double defaultValue = std::numeric_limits<double>::max();
|
||||
elevation = s_eleMgr->elevation(lonLat.x(), lonLat.y(), defaultValue);
|
||||
QVERIFY2(qFuzzyCompare(elevation, defaultValue), " error on defaultValue");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void UnitTestElevation::test_lineOfSightCalculation_data()
|
||||
{
|
||||
QTest::addColumn<QPointF>("startGeo2D");
|
||||
QTest::addColumn<double>("startObjH");
|
||||
QTest::addColumn<QPointF>("endGeo2D");
|
||||
QTest::addColumn<double>("endObjH");
|
||||
QTest::addColumn<LtsElevation::LineOfSight>("expectedResult");
|
||||
QTest::addColumn<QPointF>("startGeo2D");
|
||||
QTest::addColumn<double>("startObjH");
|
||||
QTest::addColumn<QPointF>("endGeo2D");
|
||||
QTest::addColumn<double>("endObjH");
|
||||
QTest::addColumn<LtsElevation::LineOfSight>("expectedResult");
|
||||
|
||||
|
||||
QTest::newRow("losDataset 1 ")
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 60000 10000")).geographic() << 1.0
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 60000 60000")).geographic() << 1.0
|
||||
<< LtsElevation::LineOfSight::LOS_ERROR;
|
||||
|
||||
|
||||
QTest::newRow("losDataset 1 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 60000 10000")).geographic() << 1.0
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 60000 60000")).geographic() << 1.0
|
||||
<< LtsElevation::LineOfSight::LOS_ERROR;
|
||||
QTest::newRow("losDataset 2 ")
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 1.0
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 1.0
|
||||
<< LtsElevation::LineOfSight::LOS_INVISIBLE;
|
||||
|
||||
|
||||
QTest::newRow("losDataset 2 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 1.0
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 1.0
|
||||
<< LtsElevation::LineOfSight::LOS_INVISIBLE;
|
||||
|
||||
|
||||
QTest::newRow("losDataset 3 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 20.0
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 20.0
|
||||
<< LtsElevation::LineOfSight::LOS_VISIBLE;
|
||||
|
||||
|
||||
QTest::newRow("losDataset 4 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << -1.0
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 1.0
|
||||
<< LtsElevation::LineOfSight::LOS_ERROR;
|
||||
QTest::newRow("losDataset 5 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 1.0
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << -1.0
|
||||
<< LtsElevation::LineOfSight::LOS_ERROR;
|
||||
QTest::newRow("losDataset 6 ") << LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 0.0
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 0.0
|
||||
<< LtsElevation::LineOfSight::LOS_INVISIBLE;
|
||||
QTest::newRow("losDataset 3 ")
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 20.0
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 20.0
|
||||
<< LtsElevation::LineOfSight::LOS_VISIBLE;
|
||||
|
||||
QTest::newRow("losDataset 4 ")
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << -1.0
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 1.0
|
||||
<< LtsElevation::LineOfSight::LOS_ERROR;
|
||||
QTest::newRow("losDataset 5 ")
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 1.0
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << -1.0
|
||||
<< LtsElevation::LineOfSight::LOS_ERROR;
|
||||
QTest::newRow("losDataset 6 ")
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77200 17600")).geographic() << 0.0
|
||||
<< LtsCoordTrans::UtmCoordinate::fromMgrs(QStringLiteral("32U PD 77600 17600")).geographic() << 0.0
|
||||
<< LtsElevation::LineOfSight::LOS_INVISIBLE;
|
||||
}
|
||||
|
||||
void UnitTestElevation::test_lineOfSightCalculation()
|
||||
{
|
||||
QFETCH(QPointF, startGeo2D);
|
||||
QFETCH(double, startObjH);
|
||||
QFETCH(QPointF, endGeo2D);
|
||||
QFETCH(double, endObjH);
|
||||
QFETCH(LtsElevation::LineOfSight, expectedResult);
|
||||
QFETCH(QPointF, startGeo2D);
|
||||
QFETCH(double, startObjH);
|
||||
QFETCH(QPointF, endGeo2D);
|
||||
QFETCH(double, endObjH);
|
||||
QFETCH(LtsElevation::LineOfSight, expectedResult);
|
||||
|
||||
LtsUtils::QPoint3D start3D = LtsUtils::QPoint3D::fromQPointF(startGeo2D);
|
||||
start3D.rz() = startObjH;
|
||||
start3D.rz() += s_eleMgr->elevation(start3D.x(), start3D.y());
|
||||
LtsUtils::QPoint3D start3D = LtsUtils::QPoint3D::fromQPointF(startGeo2D);
|
||||
start3D.rz() = startObjH;
|
||||
start3D.rz() += s_eleMgr->elevation(start3D.x(), start3D.y());
|
||||
|
||||
LtsUtils::QPoint3D end3D = LtsUtils::QPoint3D::fromQPointF(endGeo2D);
|
||||
end3D.rz() = endObjH;
|
||||
end3D.rz() += s_eleMgr->elevation(end3D.x(), end3D.y());
|
||||
LtsUtils::QPoint3D end3D = LtsUtils::QPoint3D::fromQPointF(endGeo2D);
|
||||
end3D.rz() = endObjH;
|
||||
end3D.rz() += s_eleMgr->elevation(end3D.x(), end3D.y());
|
||||
|
||||
LtsElevation::LineOfSight los = s_eleMgr->lineOfSightCalculation(start3D, end3D);
|
||||
NOTICE_LOG(m_logger) << "los = " << los;
|
||||
LtsElevation::LineOfSight los = s_eleMgr->lineOfSightCalculation(start3D, end3D);
|
||||
NOTICE_LOG(m_logger) << "los = " << los;
|
||||
|
||||
{
|
||||
LtsElevation::LineOfSight los2 = s_eleMgr->lineOfSightCalculation(startGeo2D, startObjH,
|
||||
endGeo2D, endObjH);
|
||||
QVERIFY2(los == los2, " got different lineOfSightCalculation result");
|
||||
}
|
||||
{
|
||||
LtsElevation::LineOfSight los2 = s_eleMgr->lineOfSightCalculation(startGeo2D, startObjH, endGeo2D, endObjH);
|
||||
QVERIFY2(los == los2, " got different lineOfSightCalculation result");
|
||||
}
|
||||
|
||||
|
||||
|
||||
QVERIFY2(los == expectedResult, " got lineOfSightCalculation result");
|
||||
QVERIFY2(los == expectedResult, " got lineOfSightCalculation result");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
app.createLogger("UnitTestElevation", "log4cxxElevationUnitTest.props");
|
||||
NGLCoreApplication app(argc, argv);
|
||||
app.createLogger("UnitTestElevation", "log4cxxElevationUnitTest.props");
|
||||
|
||||
UnitTestElevation tc;
|
||||
UnitTestElevation tc;
|
||||
|
||||
int ret = QTest::qExec(&tc, argc, argv);
|
||||
int ret = QTest::qExec(&tc, argc, argv);
|
||||
|
||||
|
||||
if (s_eleMgr)
|
||||
{
|
||||
s_eleMgr->cleanupAll();
|
||||
}
|
||||
if (s_eleMgr)
|
||||
{
|
||||
s_eleMgr->cleanupAll();
|
||||
}
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Executable → Regular
+18
-41
@@ -1,61 +1,38 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <LtsElevation/lts_elevation_manager.h>
|
||||
|
||||
#include <ElevationMap/elevation_map_manager.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QtTest/QTest>
|
||||
#include <LtsElevation/lts_elevation_manager.h>
|
||||
#include <NGLLogger/INGLLogger.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QObject>
|
||||
#include <QtTest/QTest>
|
||||
|
||||
using LOGGER_T = NGL::INGLLogger&;
|
||||
|
||||
|
||||
|
||||
|
||||
class UnitTestElevation : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
UnitTestElevation();
|
||||
public:
|
||||
UnitTestElevation();
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
private Q_SLOTS:
|
||||
void initTestCase();
|
||||
|
||||
|
||||
|
||||
|
||||
void init();
|
||||
|
||||
void test_elevation_data();
|
||||
void test_elevation();
|
||||
|
||||
void initTestCase();
|
||||
void test_elevation_isCovered();
|
||||
void test_elevation_defaultValue();
|
||||
|
||||
void init();
|
||||
|
||||
void test_lineOfSightCalculation_data();
|
||||
void test_lineOfSightCalculation();
|
||||
|
||||
|
||||
|
||||
void test_elevation_data();
|
||||
void test_elevation();
|
||||
|
||||
void test_elevation_isCovered();
|
||||
void test_elevation_defaultValue();
|
||||
|
||||
void test_lineOfSightCalculation_data();
|
||||
void test_lineOfSightCalculation();
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
private:
|
||||
NGL::INGLLogger& m_logger;
|
||||
};
|
||||
Reference in new issue
Block a user