Skip to content

Commit 8df6520

Browse files
committed
std::array -> std::setに
reference point -> origin point
1 parent eff0254 commit 8df6520

2 files changed

Lines changed: 22 additions & 15 deletions

File tree

include/plateau/geometry/geo_coordinate.h

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "citygml/vecs.hpp"
44
#include "citygml/cityobject.h"
55
#include <array>
6+
#include <set>
67
#include <utility>
78

89
namespace plateau::geometry {
@@ -115,23 +116,13 @@ namespace plateau::geometry {
115116
static constexpr int default_epsg = 6697;
116117

117118
// EPSGとZone IDのマッピング
118-
static constexpr std::array<std::pair<int, int>, 13> epsg_to_zone = { {
119-
{10162, 1}, {10163, 2}, {10164, 3}, {10165, 4}, {10166, 5},
120-
{10167, 6}, {10168, 7}, {10169, 8}, {10170, 9}, {10171, 10},
121-
{10172, 11}, {10173, 12}, {10174, 13}
122-
} };
119+
static const std::set<std::pair<int, int>> epsg_to_zone;
123120

124121
// Zone IDごとの座標データ
125-
static constexpr std::array<std::pair<int, std::array<double, 3>>, 13> zone_to_point = { {
126-
{1, {33.0, 129.5, 0.0}}, {2, {33.0, 131.0, 0.0}}, {3, {36.0, 132.166667, 0.0}},
127-
{4, {33.0, 133.5, 0.0}}, {5, {36.0, 134.333333, 0.0}}, {6, {36.0, 136.0, 0.0}},
128-
{7, {36.0, 137.166667, 0.0}}, {8, {36.0, 138.5, 0.0}}, {9, {35.0, 139.833333, 0.0}},
129-
{10, {40.0, 140.833333, 0.0}}, {11, {44.0, 140.25, 0.0}}, {12, {44.0, 142.0, 0.0}},
130-
{13, {43.0, 144.0, 0.0}}
131-
} };
122+
static const std::set<std::pair<int, std::array<double, 3>>> zone_to_point;
132123

133124
// EPSGごとのzone取得
134-
static constexpr int GetZoneId(int epsg) {
125+
static const int GetZoneId(int epsg) {
135126
for (const auto& pair : epsg_to_zone) {
136127
if (pair.first == epsg) {
137128
return pair.second;
@@ -141,7 +132,7 @@ namespace plateau::geometry {
141132
}
142133

143134
// EPSGごとの基準点取得
144-
static GeoCoordinate GetReferencePoint(int epsg) {
135+
static GeoCoordinate GetOriginPoint(int epsg) {
145136
const int zone = GetZoneId(epsg);
146137
if (zone != 0) {
147138
for (const auto& pair : zone_to_point) {
@@ -163,4 +154,20 @@ namespace plateau::geometry {
163154
return !(epsg >= 10162 && epsg <= 10174);
164155
}
165156
};
157+
158+
// EPSGとZone IDのマッピング
159+
inline const std::set<std::pair<int, int>> CoordinateReferenceFactory::epsg_to_zone = {
160+
{10162, 1}, {10163, 2}, {10164, 3}, {10165, 4}, {10166, 5},
161+
{10167, 6}, {10168, 7}, {10169, 8}, {10170, 9}, {10171, 10},
162+
{10172, 11}, {10173, 12}, {10174, 13}
163+
};
164+
165+
// Zone IDごとの座標データ
166+
inline const std::set<std::pair<int, std::array<double, 3>>> CoordinateReferenceFactory::zone_to_point = {
167+
{1, {33.0, 129.5, 0.0}}, {2, {33.0, 131.0, 0.0}}, {3, {36.0, 132.166667, 0.0}},
168+
{4, {33.0, 133.5, 0.0}}, {5, {36.0, 134.333333, 0.0}}, {6, {36.0, 136.0, 0.0}},
169+
{7, {36.0, 137.166667, 0.0}}, {8, {36.0, 138.5, 0.0}}, {9, {35.0, 139.833333, 0.0}},
170+
{10, {40.0, 140.833333, 0.0}}, {11, {44.0, 140.25, 0.0}}, {12, {44.0, 142.0, 0.0}},
171+
{13, {43.0, 144.0, 0.0}}
172+
};
166173
}

test/test_geo_coordinate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace plateau::geometry {
3838
ASSERT_FALSE(CoordinateReferenceFactory::IsPolarCoordinateSystem(10169));
3939
ASSERT_TRUE(CoordinateReferenceFactory::IsPolarCoordinateSystem(6697));
4040

41-
const auto& refPoint = CoordinateReferenceFactory::GetReferencePoint(10169);
41+
const auto& refPoint = CoordinateReferenceFactory::GetOriginPoint(10169);
4242
ASSERT_EQ(36.0, refPoint.latitude);
4343
ASSERT_EQ(138.5, refPoint.longitude);
4444
}

0 commit comments

Comments
 (0)