@@ -27,12 +27,15 @@ namespace plateau::dataset {
2727
2828 GmlFile::GmlFile (const std::string& path) // NOLINT
2929 : path_(path), is_valid_(false ), is_local_(true ), max_lod_(-1 ) {
30+ // 上の行の is_valid_ と is_local_ の設定は一時的なもので、すぐ applyPath() によって書き換えられます。
3031 applyPath ();
3132 }
3233
33- GmlFile::GmlFile (const std::string& path, const int max_lod) // NOLINT
34- : path_(path), is_valid_(false ), is_local_(true ), max_lod_(max_lod) {
35- applyPath ();
34+ // / サーバーモードで使うコンストラクタです。GMLファイルのダウンロードに使う Client を指定します。
35+ GmlFile::GmlFile (const std::string& path, const network::Client& client, int max_lod)
36+ : GmlFile(path){
37+ client_ = client;
38+ max_lod_ = max_lod;
3639 }
3740
3841 const std::string& GmlFile::getPath () const {
@@ -281,10 +284,9 @@ namespace plateau::dataset {
281284 }
282285
283286 void fetchServer (const fs::path& gml_file_path, const fs::path& gml_relative_path_from_udx, const fs::path& destination_udx_path,
284- const fs::path& gml_destination_path, GmlFile& copied_gml_file) {
287+ const fs::path& gml_destination_path, GmlFile& copied_gml_file, const network::Client& client ) {
285288 auto destination_dir = gml_destination_path.parent_path ();
286289 // gmlファイルをダウンロードします。
287- auto client = Client ();
288290 client.download (destination_dir.u8string (), gml_file_path.u8string ());
289291 auto downloaded_path = destination_dir;
290292 downloaded_path /= gml_file_path.filename ();
@@ -330,11 +332,16 @@ namespace plateau::dataset {
330332 prepareFetch (fs::u8path (getPath ()), fs::u8path (destination_root_path), gml_relative_path_from_udx, destination_udx_path,
331333 gml_destination_path);
332334 if (is_local_) {
335+ // ローカルモード
333336 fetchLocal (fs::u8path (path_), gml_relative_path_from_udx, destination_udx_path, gml_destination_path,
334337 copied_gml_file);
335338 } else {
339+ // サーバーモード
340+ if (!client_.has_value ()) {
341+ throw std::runtime_error (" Client is nullopt." );
342+ }
336343 fetchServer (fs::u8path (path_), gml_relative_path_from_udx, destination_udx_path, gml_destination_path,
337- copied_gml_file);
344+ copied_gml_file, client_. value () );
338345 }
339346 }
340347
0 commit comments