Skip to content

Commit 545f1f5

Browse files
committed
AI のコメント修正
1 parent b40aa40 commit 545f1f5

File tree

5 files changed

+46
-55
lines changed

5 files changed

+46
-55
lines changed

include/plateau/geometry/geo_coordinate.h

Lines changed: 41 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
#include "citygml/vecs.hpp"
44
#include "citygml/cityobject.h"
5-
5+
#include <array>
6+
#include <utility>
67

78
namespace plateau::geometry {
89

@@ -107,69 +108,59 @@ namespace plateau::geometry {
107108
}
108109
};
109110

110-
/**
111-
* 平面直角座標判定、平面直角座標の基準点取得
112-
*/
111+
/**
112+
* 平面直角座標系の判定、平面直角座標の基準点取得
113+
*/
113114
struct CoordinateReferenceFactory {
114-
115115
static constexpr int default_epsg = 6697;
116116

117+
// 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+
} };
123+
124+
// 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+
} };
132+
117133
// EPSGごとのzone取得
118-
static int GetZoneId(int epsg) {
119-
// 日本測地系2011(JGD2011)に基づく平面直角座標系
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;
134+
static constexpr int GetZoneId(int epsg) {
135+
for (const auto& pair : epsg_to_zone) {
136+
if (pair.first == epsg) {
137+
return pair.second;
138+
}
139+
}
140+
return 0;
127141
}
128142

129143
// EPSGごとの基準点取得
130144
static GeoCoordinate GetReferencePoint(int epsg) {
131145
const int zone = GetZoneId(epsg);
132-
if (zone != 0)
133-
return GetReferencePointByZone(zone);
146+
if (zone != 0) {
147+
for (const auto& pair : zone_to_point) {
148+
if (pair.first == zone) {
149+
const auto& coords = pair.second;
150+
return GeoCoordinate(coords[0], coords[1], coords[2]);
151+
}
152+
}
153+
}
134154
return GeoCoordinate();
135155
}
136156

137-
// Zone IDごとの基準点
138-
// zoneに紐づく基準点はPolarToPlaneCartesianにハードコードで持っているが値が取得できないので、ここで定義
139-
static GeoCoordinate GetReferencePointByZone(int zone_id) {
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();
163-
}
164-
165157
// 極座標系・平面直角座標系判定
158+
// 平面直角座標系の区分についてはこちらを参照してください :
159+
// https://www.mlit.go.jp/plateaudocument/toc9/toc9_08/toc9_08_04/
160+
// “該当範囲でなければ極座標” と単純化していますが、
161+
// EPSG 4301(JGD2000) 等の別 CRS を誤って極座標と判定する恐れがあります。
166162
static bool IsPolarCoordinateSystem(int epsg) {
167-
// 平面直角座標系の区分についてはこちらを参照してください :
168-
// https://www.mlit.go.jp/plateaudocument/toc9/toc9_08/toc9_08_04/
169-
if (epsg >= 10162 && epsg <= 10174) {
170-
return false;
171-
}
172-
return true;
163+
return !(epsg >= 10162 && epsg <= 10174);
173164
}
174165
};
175166
}

src/polygon_mesh/mesh_factory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ namespace plateau::polygonMesh {
128128
void findAllPolygonsInGeometry(
129129
const Geometry& geom, std::list<const citygml::Polygon*>& polygons,
130130
const unsigned lod, long long& out_vertices_count,
131-
const std::vector<plateau::geometry::Extent> extents, const MeshExtractOptions& options) {
131+
const std::vector<plateau::geometry::Extent>& extents, const MeshExtractOptions& options) {
132132

133133
// 子のジオメトリのポリゴンをすべて取得
134134
const unsigned int child_count = geom.getGeometriesCount();

test/test_mesh_extractor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ namespace plateau::polygonMesh {
233233

234234
// Extracted Model
235235
auto model = MeshExtractor::extract(*city_model, mesh_extract_options);
236-
ASSERT_GE(1, model->getRootNodeCount());
236+
ASSERT_GE(model->getRootNodeCount(),1);
237237
const auto& lod_node = model->getRootNodeAt(0);
238-
ASSERT_GE(1, lod_node.getChildCount());
238+
ASSERT_GE(lod_node.getChildCount(),1);
239239
const auto& first_model_node = lod_node.getChildAt(0);
240240
const auto& mesh = first_model_node.getMesh();
241241

wrappers/csharp/LibPLATEAU.NET/CSharpPLATEAU/Geometries/CoordinateReferenceFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace PLATEAU.Geometries
99
public static class CoordinateReferenceFactory
1010
{
1111

12-
public static readonly int DEFAULT_EPSG = 6697;
12+
public const int DEFAULT_EPSG = 6697;
1313

1414
/// <summary>
1515
/// 平面直角座標系への変換が必要なGMLファイルかどうかを返します。

wrappers/csharp/LibPLATEAU.NET/CSharpPLATEAU/Geometries/GeoReference.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public GeoCoordinate Unproject(PlateauVector3d point)
142142
return outLatLon;
143143
}
144144

145-
public PlateauVector3d Convert(PlateauVector3d point, bool convertAxis, int epsg)
145+
public PlateauVector3d Convert(PlateauVector3d point, bool convertAxis, int epsg = CoordinateReferenceFactory.DEFAULT_EPSG)
146146
{
147147
var result = NativeMethods.plateau_geo_reference_convert(
148148
Handle, out var outXyz,

0 commit comments

Comments
 (0)