|
| 1 | +#include <gtest/gtest.h> |
| 2 | +#include <plateau/geometry/geo_coordinate.h> |
| 3 | +#include <plateau/geometry/geo_reference.h> |
| 4 | +#include "../src/geometry/polar_to_plane_cartesian.cpp" |
| 5 | + |
| 6 | +namespace plateau::geometry { |
| 7 | + class GeoReferenceTest : public ::testing::Test { |
| 8 | + protected: |
| 9 | + void SetUp() override { |
| 10 | + } |
| 11 | + void TearDown() override { |
| 12 | + } |
| 13 | + |
| 14 | + // テスト設定 |
| 15 | + int zone_id = 9; |
| 16 | + TVec3d ref_point = TVec3d(0, 0, 0); |
| 17 | + float unit_scale = 1.0; |
| 18 | + CoordinateSystem coordinate = CoordinateSystem::EUN; |
| 19 | + GeoReference ref = GeoReference(zone_id, ref_point, unit_scale, coordinate); |
| 20 | + TVec3d base_point = TVec3d(100, 100, 0); |
| 21 | + }; |
| 22 | + |
| 23 | + TEST_F(GeoReferenceTest, ConvertAxisProject) { // NOLINT |
| 24 | + // 平面直角座標変換・座標軸変換を行う |
| 25 | + TVec3d converted = ref.convert(base_point, true, true); |
| 26 | + TVec3d projected = ref.project(base_point); |
| 27 | + |
| 28 | + // Expected |
| 29 | + TVec3d position = base_point; |
| 30 | + PolarToPlaneCartesian().project(position, zone_id); |
| 31 | + TVec3 expected_point = GeoReference::convertAxisFromENUTo(coordinate, position); |
| 32 | + expected_point = expected_point / unit_scale - ref_point; |
| 33 | + |
| 34 | + ASSERT_EQ(expected_point, converted); |
| 35 | + ASSERT_EQ(expected_point, projected); |
| 36 | + } |
| 37 | + |
| 38 | + TEST_F(GeoReferenceTest, ConvertProjectOnly) { // NOLINT |
| 39 | + // 平面直角座標変換を行う・座標軸変換を行わない |
| 40 | + TVec3d converted = ref.convert(base_point, false, true); |
| 41 | + TVec3d projected = ref.projectWithoutAxisConvert(base_point); |
| 42 | + |
| 43 | + // Expected |
| 44 | + TVec3d position = base_point; |
| 45 | + PolarToPlaneCartesian().project(position, zone_id); |
| 46 | + TVec3 expected_point = position / unit_scale - GeoReference::convertAxisToENU(coordinate, ref_point); |
| 47 | + |
| 48 | + ASSERT_EQ(expected_point, converted); |
| 49 | + ASSERT_EQ(expected_point, projected); |
| 50 | + } |
| 51 | + |
| 52 | + TEST_F(GeoReferenceTest, ConvertAxisOnly) { // NOLINT |
| 53 | + // 平面直角座標変換を行わない・座標軸変換を行う |
| 54 | + TVec3d point = ref.convert(base_point, true, false); |
| 55 | + |
| 56 | + // Expected |
| 57 | + TVec3 expected_point = GeoReference::convertAxisFromENUTo(coordinate, base_point); |
| 58 | + expected_point = expected_point / unit_scale - ref_point; |
| 59 | + |
| 60 | + ASSERT_EQ(expected_point, point); |
| 61 | + } |
| 62 | + |
| 63 | + TEST_F(GeoReferenceTest, ConvertOnly) { // NOLINT |
| 64 | + // 平面直角座標変換・座標軸変換を行わない |
| 65 | + TVec3d point = ref.convert(base_point, false, false); |
| 66 | + |
| 67 | + // Expected |
| 68 | + TVec3 expected_point = base_point / unit_scale - GeoReference::convertAxisToENU(coordinate, ref_point); |
| 69 | + |
| 70 | + ASSERT_EQ(expected_point, point); |
| 71 | + } |
| 72 | + |
| 73 | + // fetch のテストは test_dataset.cpp にあります。 |
| 74 | + |
| 75 | +} |
0 commit comments