|
3 | 3 | #include "citygml/vecs.hpp" |
4 | 4 | #include "citygml/cityobject.h" |
5 | 5 | #include <array> |
6 | | -#include <set> |
| 6 | +#include <unordered_map> |
7 | 7 | #include <utility> |
8 | 8 |
|
9 | 9 | namespace plateau::geometry { |
@@ -109,65 +109,53 @@ namespace plateau::geometry { |
109 | 109 | } |
110 | 110 | }; |
111 | 111 |
|
112 | | - /** |
113 | | - * 平面直角座標系の判定、平面直角座標の基準点取得 |
114 | | - */ |
| 112 | + /** |
| 113 | + * 平面直角座標系の判定、平面直角座標の基準点取得 |
| 114 | + */ |
115 | 115 | struct CoordinateReferenceFactory { |
116 | 116 | static constexpr int default_epsg = 6697; |
117 | | - |
118 | 117 | // EPSGとZone IDのマッピング |
119 | | - static const std::set<std::pair<int, int>> epsg_to_zone; |
120 | | - |
| 118 | + static const std::unordered_map<int, int> epsg_to_zone; |
121 | 119 | // Zone IDごとの座標データ |
122 | | - static const std::set<std::pair<int, std::array<double, 3>>> zone_to_point; |
123 | | - |
| 120 | + static const std::unordered_map<int, std::array<double, 3>> zone_to_point; |
124 | 121 | // EPSGごとのzone取得 |
125 | | - static const int GetZoneId(int epsg) { |
126 | | - for (const auto& pair : epsg_to_zone) { |
127 | | - if (pair.first == epsg) { |
128 | | - return pair.second; |
129 | | - } |
| 122 | + static int GetZoneId(int epsg) { |
| 123 | + auto it = epsg_to_zone.find(epsg); |
| 124 | + if (it != epsg_to_zone.end()) { |
| 125 | + return it->second; |
130 | 126 | } |
131 | 127 | return 0; |
132 | 128 | } |
133 | | - |
134 | 129 | // EPSGごとの基準点取得 |
135 | 130 | static GeoCoordinate GetOriginPoint(int epsg) { |
136 | 131 | const int zone = GetZoneId(epsg); |
137 | 132 | if (zone != 0) { |
138 | | - for (const auto& pair : zone_to_point) { |
139 | | - if (pair.first == zone) { |
140 | | - const auto& coords = pair.second; |
141 | | - return GeoCoordinate(coords[0], coords[1], coords[2]); |
142 | | - } |
| 133 | + auto it = zone_to_point.find(zone); |
| 134 | + if (it != zone_to_point.end()) { |
| 135 | + const auto& coords = it->second; |
| 136 | + return GeoCoordinate(coords[0], coords[1], coords[2]); |
143 | 137 | } |
144 | 138 | } |
145 | 139 | return GeoCoordinate(); |
146 | 140 | } |
147 | | - |
148 | 141 | // 極座標系・平面直角座標系判定 |
149 | | - // 平面直角座標系の区分についてはこちらを参照してください : |
150 | | - // https://www.mlit.go.jp/plateaudocument/toc9/toc9_08/toc9_08_04/ |
151 | | - // “該当範囲でなければ極座標” と単純化していますが、 |
152 | | - // EPSG 4301(JGD2000) 等の別 CRS を誤って極座標と判定する恐れがあります。 |
153 | 142 | static bool IsPolarCoordinateSystem(int epsg) { |
154 | | - return !(epsg >= 10162 && epsg <= 10174); |
| 143 | + // 平面直角座標系(EPSG 10162~10174)かどうかを明示的に確認 |
| 144 | + return epsg_to_zone.find(epsg) == epsg_to_zone.end(); |
155 | 145 | } |
156 | 146 | }; |
157 | | - |
158 | 147 | // EPSGとZone IDのマッピング |
159 | | - inline const std::set<std::pair<int, int>> CoordinateReferenceFactory::epsg_to_zone = { |
| 148 | + inline const std::unordered_map<int, int> CoordinateReferenceFactory::epsg_to_zone = { |
160 | 149 | {10162, 1}, {10163, 2}, {10164, 3}, {10165, 4}, {10166, 5}, |
161 | 150 | {10167, 6}, {10168, 7}, {10169, 8}, {10170, 9}, {10171, 10}, |
162 | 151 | {10172, 11}, {10173, 12}, {10174, 13} |
163 | 152 | }; |
164 | | - |
165 | 153 | // 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}}, |
| 154 | + inline const std::unordered_map<int, std::array<double, 3>> CoordinateReferenceFactory::zone_to_point = { |
| 155 | + {1, {33.0, 129.5, 0.0}}, {2, {33.0, 131.0, 0.0}}, {3, {36.0, 132.166667, 0.0}}, |
| 156 | + {4, {33.0, 133.5, 0.0}}, {5, {36.0, 134.333333, 0.0}}, {6, {36.0, 136.0, 0.0}}, |
| 157 | + {7, {36.0, 137.166667, 0.0}}, {8, {36.0, 138.5, 0.0}}, {9, {35.0, 139.833333, 0.0}}, |
| 158 | + {10, {40.0, 140.833333, 0.0}}, {11, {44.0, 140.25, 0.0}}, {12, {44.0, 142.0, 0.0}}, |
171 | 159 | {13, {43.0, 144.0, 0.0}} |
172 | 160 | }; |
173 | 161 | } |
0 commit comments