Skip to content

Commit b40aa40

Browse files
committed
refactoring
1 parent 46601fd commit b40aa40

File tree

4 files changed

+36
-88
lines changed

4 files changed

+36
-88
lines changed

include/plateau/geometry/geo_coordinate.h

Lines changed: 31 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -112,51 +112,18 @@ namespace plateau::geometry {
112112
*/
113113
struct CoordinateReferenceFactory {
114114

115-
static constexpr int default_epsg_ = 6697;
115+
static constexpr int default_epsg = 6697;
116116

117117
// EPSGごとのzone取得
118118
static int GetZoneId(int epsg) {
119119
// 日本測地系2011(JGD2011)に基づく平面直角座標系
120-
if (epsg == 10162) {
121-
return 1; // 1系
122-
}
123-
else if (epsg == 10163) {
124-
return 2; // 2系
125-
}
126-
else if (epsg == 10164) {
127-
return 3; // 3系
128-
}
129-
else if (epsg == 10165) {
130-
return 4; // 4系
131-
}
132-
else if (epsg == 10166) {
133-
return 5; // 5系
134-
}
135-
else if (epsg == 10167) {
136-
return 6; // 6系
137-
}
138-
else if (epsg == 10168) {
139-
return 7; // 7系
140-
}
141-
else if (epsg == 10169) {
142-
return 8; // 8系
143-
}
144-
else if (epsg == 10170) {
145-
return 9; // 9系
146-
}
147-
else if (epsg == 10171) {
148-
return 10; // 10系
149-
}
150-
else if (epsg == 10172) {
151-
return 11; // 11系
152-
}
153-
else if (epsg == 10173) {
154-
return 12; // 12系
155-
}
156-
else if (epsg == 10174) {
157-
return 13; // 13系
158-
}
159-
return 0;
120+
static const std::map<int, int> epsg_to_zone = {
121+
{10162, 1}, {10163, 2}, {10164, 3}, {10165, 4}, {10166, 5},
122+
{10167, 6}, {10168, 7}, {10169, 8}, {10170, 9}, {10171, 10},
123+
{10172, 11}, {10173, 12}, {10174, 13}
124+
};
125+
auto it = epsg_to_zone.find(epsg);
126+
return it != epsg_to_zone.end() ? it->second : 0;
160127
}
161128

162129
// EPSGごとの基準点取得
@@ -170,48 +137,29 @@ namespace plateau::geometry {
170137
// Zone IDごとの基準点
171138
// zoneに紐づく基準点はPolarToPlaneCartesianにハードコードで持っているが値が取得できないので、ここで定義
172139
static GeoCoordinate GetReferencePointByZone(int zone_id) {
173-
switch (zone_id) {
174-
case 1:
175-
return GeoCoordinate(33, 129.5, 0);
176-
case 2:
177-
return GeoCoordinate(33, 131, 0);
178-
case 3:
179-
return GeoCoordinate(36, 132.166667, 0);
180-
case 4:
181-
return GeoCoordinate(33, 133.5, 0);
182-
case 5:
183-
return GeoCoordinate(36, 134.333333, 0);
184-
case 6:
185-
return GeoCoordinate(36, 136, 0);
186-
case 7:
187-
return GeoCoordinate(36, 137.166667, 0);
188-
case 8:
189-
return GeoCoordinate(36, 138.5, 0);
190-
case 9:
191-
return GeoCoordinate(35, 139.833333, 0);
192-
case 10:
193-
return GeoCoordinate(40, 140.833333, 0);
194-
case 11:
195-
return GeoCoordinate(44, 140.25, 0);
196-
case 12:
197-
return GeoCoordinate(44, 142, 0);
198-
case 13:
199-
return GeoCoordinate(43, 144, 0);
200-
case 14:
201-
return GeoCoordinate(26, 142, 0);
202-
case 15:
203-
return GeoCoordinate(26, 127.5, 0);
204-
case 16:
205-
return GeoCoordinate(24, 124, 0);
206-
case 17:
207-
return GeoCoordinate(31, 131, 0);
208-
case 18:
209-
return GeoCoordinate(20, 136, 0);
210-
case 19:
211-
return GeoCoordinate(25, 154, 0);
212-
default:
213-
return GeoCoordinate();
214-
}
140+
static const std::map<int, GeoCoordinate> zone_to_point = {
141+
{1, GeoCoordinate(33, 129.5, 0)},
142+
{2, GeoCoordinate(33, 131, 0)},
143+
{3, GeoCoordinate(36, 132.166667, 0)},
144+
{4, GeoCoordinate(33, 133.5, 0)},
145+
{5, GeoCoordinate(36, 134.333333, 0)},
146+
{6, GeoCoordinate(36, 136, 0)},
147+
{7, GeoCoordinate(36, 137.166667, 0)},
148+
{8, GeoCoordinate(36, 138.5, 0)},
149+
{9, GeoCoordinate(35, 139.833333, 0)},
150+
{10, GeoCoordinate(40, 140.833333, 0)},
151+
{11, GeoCoordinate(44, 140.25, 0)},
152+
{12, GeoCoordinate(44, 142, 0)},
153+
{13, GeoCoordinate(43, 144, 0)},
154+
{14, GeoCoordinate(26, 142, 0)},
155+
{15, GeoCoordinate(26, 127.5, 0)},
156+
{16, GeoCoordinate(24, 124, 0)},
157+
{17, GeoCoordinate(31, 131, 0)},
158+
{18, GeoCoordinate(20, 136, 0)},
159+
{19, GeoCoordinate(25, 154, 0)}
160+
};
161+
auto it = zone_to_point.find(zone_id);
162+
return it != zone_to_point.end() ? it->second : GeoCoordinate();
215163
}
216164

217165
// 極座標系・平面直角座標系判定

include/plateau/geometry/geo_reference.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace plateau::geometry {
2626
/// project の座標軸変換をしない版です。座標軸は ENU → ENU であるとします。 reference_point_ は ENUに変換されます。
2727
TVec3d projectWithoutAxisConvert(const TVec3d& lat_lon) const;
2828
TVec3d convertAxisToENU(const TVec3d& vertex) const;
29-
TVec3d convert(const TVec3d& lat_lon, const bool convert_axis = true, const int epsg = CoordinateReferenceFactory::default_epsg_) const;
29+
TVec3d convert(const TVec3d& lat_lon, const bool convert_axis = true, const int epsg = CoordinateReferenceFactory::default_epsg) const;
3030
static TVec3d convertAxisFromENUTo(CoordinateSystem axis, const TVec3d& vertex);
3131
static TVec3d convertAxisToENU(CoordinateSystem axis, const TVec3d& vertex);
3232

include/plateau/polygon_mesh/mesh_extract_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace plateau::polygonMesh {
3838
attach_map_tile(true),
3939
map_tile_zoom_level(15),
4040
map_tile_url("https://cyberjapandata.gsi.go.jp/xyz/seamlessphoto/{z}/{x}/{y}.jpg"),
41-
epsg_code(plateau::geometry::CoordinateReferenceFactory::default_epsg_)
41+
epsg_code(plateau::geometry::CoordinateReferenceFactory::default_epsg)
4242
{}
4343

4444
public:

src/dataset/gml_file.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ namespace plateau::dataset {
5454
return GridCode::createRaw(grid_code_->get());
5555
}
5656

57-
double GmlFile::getEpsg() const {
57+
double GmlFile::getEpsg() const {
5858
try {
59-
return epsg_.empty() ? 6697 : std::stod(epsg_);
59+
return epsg_.empty() ? plateau::geometry::CoordinateReferenceFactory::default_epsg : std::stod(epsg_);
6060
}
6161
catch (const std::exception&) {
62-
return 6697;
62+
return plateau::geometry::CoordinateReferenceFactory::default_epsg;
6363
}
6464
}
6565

0 commit comments

Comments
 (0)