diff --git a/.clangd b/.clangd
new file mode 100644
index 00000000..1085221b
--- /dev/null
+++ b/.clangd
@@ -0,0 +1,7 @@
+CompileFlags:
+ If:
+ PathMatch: [.*]
+ Condition: "system(windows)"
+ CompilationDatabase: out/build/x64-Debug-Unity
+ Remove: [-fPIC]
+ Add: [--target=x86_64-pc-windows-msvc]
diff --git a/.gitignore b/.gitignore
index eacfc354..512bf824 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@
-
# fbx_sdk は再配布禁止のため、ご自分で用意していただく形になります。
/3rdparty/fbx_sdk/
@@ -22,8 +21,10 @@ _deps
obj
bin
-# Visual Studio
+# Editor settings
.vs
+.vscode
+.idea
# Resharper User config
*.DotSettings.user
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index be1ca900..57d9b2b4 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -15,8 +15,6 @@
-
-
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4c5141f4..030d9926 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,7 +22,7 @@
# .soファイルが存在しても、 .so が依存する .so ファイルが存在しない場合に DllNotFoundException になります。
# 次のコマンドで .so がどのようなライブラリに依存するか調べると良いです。
# objdump -x libplateau.so | grep NEEDED
-# ldd ./libplateau.so | grep "not found”
+# ldd ./libplateau.so | grep "not found"
cmake_minimum_required(VERSION 3.8)
@@ -79,6 +79,9 @@ if(WIN32) # CMake文法上の WIN32
add_definitions(-D WIN32) # C言語の #define キーワードとしての WIN32
endif()
+# clangdで静的解析するための情報を出力
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+
# libjpeg-turboが複数architecture向けビルドをサポートしていないため限定
# https://github.com/libjpeg-turbo/libjpeg-turbo/blob/main/CMakeLists.txt#L101
set(COUNT 1)
diff --git a/include/plateau/dataset/gml_file.h b/include/plateau/dataset/gml_file.h
index e9954d30..988d3433 100644
--- a/include/plateau/dataset/gml_file.h
+++ b/include/plateau/dataset/gml_file.h
@@ -1,7 +1,6 @@
#pragma once
#include
-#include
#include
#include
#include "plateau/network/client.h"
@@ -20,7 +19,8 @@ namespace plateau::dataset {
const std::string& getPath() const;
void setPath(const std::string& path);
- MeshCode getMeshCode() const;
+ std::shared_ptr getGridCode() const;
+ GridCode* getGridCodeRaw() const; // 寿命管理をDLL利用者に任せる用です
double getEpsg() const;
bool isPolarCoordinateSystem() const;
const std::string& getFeatureType() const;
@@ -63,7 +63,7 @@ namespace plateau::dataset {
private:
std::string path_;
- std::string code_;
+ std::shared_ptr grid_code_;
std::string feature_type_;
std::string epsg_;
bool is_valid_;
diff --git a/include/plateau/dataset/grid_code.h b/include/plateau/dataset/grid_code.h
new file mode 100644
index 00000000..e8ecd41f
--- /dev/null
+++ b/include/plateau/dataset/grid_code.h
@@ -0,0 +1,93 @@
+#pragma once
+
+#include
+#include
+#include
+#include "plateau/geometry/geo_coordinate.h"
+
+namespace plateau::dataset {
+ class StandardMapGrid;
+ class MeshCode;
+
+ /**
+ * \brief 地図の区画を表すコードの基底クラスです。
+ *
+ * メッシュコードや国土基本図図郭など、地図の区画を表現するコードシステムの共通機能を提供します。
+ */
+ class LIBPLATEAU_EXPORT GridCode {
+ public:
+ virtual ~GridCode() = default;
+
+ /**
+ * \brief コードを文字列として取得します。
+ */
+ virtual std::string get() const = 0;
+
+ /**
+ * \brief コードが表す緯度経度範囲を取得します。
+ */
+ virtual geometry::Extent getExtent() const = 0;
+
+ /**
+ * \brief コードが適切な値かどうかを返します。
+ */
+ virtual bool isValid() const = 0;
+
+ /**
+ * \brief 1段階上のレベルのグリッドコードに変換します。
+ */
+ virtual std::shared_ptr upper() const = 0;
+
+ /**
+ * \brief upper()のP/Invokeから呼び出す版です。newして返すので、利用者が適切に廃棄する必要があります。
+ */
+ virtual GridCode* upperRaw() const = 0;
+
+ /**
+ * \brief コードのレベル(詳細度)を取得します。
+ */
+ virtual int getLevel() const = 0;
+
+ /**
+ * \brief コードのレベル(詳細度)が、PLATEAUの仕様上考えられる中でもっとも広域であるときにtrueを返します。
+ */
+ virtual bool isLargestLevel() const = 0;
+
+ /**
+ * \brief コードのレベル(詳細度)が、PLATEAUの典型的な建物のGMLファイルのレベルよりも詳細である場合にtrueを返します。
+ */
+ virtual bool isSmallerThanNormalGml() const = 0;
+
+ /**
+ * \brief コードのレベル(詳細度)が、PLATEAUの典型的な建物のGMLファイルのレベルである場合にtrueを返します。
+ */
+ virtual bool isNormalGmlLevel() const = 0;
+
+
+ /**
+ * \brief 与えられたコードから適切なGridCodeの派生クラスのインスタンスを作成します。
+ * \param code コード文字列
+ * \return コードの形式に応じてMeshCodeまたはStandardMapGridのインスタンスを返します。
+ * \throw std::invalid_argument コードの形式が不正な場合
+ */
+ static std::shared_ptr create(const std::string& code);
+
+ /**
+ * \brief 与えられたコードから適切なGridCodeの派生クラスのインスタンスを作成します。
+ * \param code コード文字列
+ * \return コードの形式に応じてMeshCodeまたはStandardMapGridのインスタンスを返します。生ポインタで返されます。
+ * \throw std::invalid_argument コードの形式が不正な場合
+ */
+ static GridCode* createRaw(const std::string& code);
+
+ };
+
+ struct GridCodeComparator {
+ bool operator()(const std::shared_ptr& lhs, const std::shared_ptr& rhs) const {
+ if(lhs == nullptr && rhs == nullptr) return false;
+ if(lhs != nullptr && rhs == nullptr) return false;
+ if(lhs == nullptr) return true;
+ return lhs->get() < rhs->get();
+ }
+ };
+}
diff --git a/include/plateau/dataset/i_dataset_accessor.h b/include/plateau/dataset/i_dataset_accessor.h
index f46387bb..85c2bd43 100644
--- a/include/plateau/dataset/i_dataset_accessor.h
+++ b/include/plateau/dataset/i_dataset_accessor.h
@@ -3,6 +3,8 @@
#include
#include
#include
+#include
+#include
namespace plateau::geometry {
class GeoReference;
@@ -14,7 +16,7 @@ namespace plateau::dataset {
*/
class LIBPLATEAU_EXPORT UdxSubFolder {
public:
- UdxSubFolder(std::string name)
+ explicit UdxSubFolder(std::string name)
: name_(std::move(name)) {
}
@@ -25,11 +27,11 @@ namespace plateau::dataset {
return name_;
}
- operator std::string& () {
+ explicit operator std::string& () {
return name_;
}
- operator std::string() const {
+ explicit operator std::string() const {
return name_;
}
@@ -93,9 +95,9 @@ namespace plateau::dataset {
* \brief GMLファイル群のうち、範囲が extent の内部であり、パッケージ種が package であるものを vector で返します。
* なお、 package はフラグの集合と見なされるので、複数のビットを立てることで複数の指定が可能です。
*/
- virtual std::shared_ptr> getGmlFiles(const PredefinedCityModelPackage package) = 0;
+ virtual std::shared_ptr> getGmlFiles(PredefinedCityModelPackage package) = 0;
- virtual void getGmlFiles(const PredefinedCityModelPackage package,
+ virtual void getGmlFiles(PredefinedCityModelPackage package,
std::vector& out_vector) = 0;
/**
@@ -114,22 +116,23 @@ namespace plateau::dataset {
/**
* \brief メッシュコードで都市モデルデータをフィルタリングします。
- * \param mesh_codes 欲しい地域IDのvector
+ * \param grid_codes 欲しい地域IDのvector
* \param collection フィルタリングされた都市モデルデータの格納先
*/
- virtual void filterByMeshCodes(const std::vector& mesh_codes, IDatasetAccessor& collection) const = 0;
+ virtual void filterByGridCodes(const std::vector& grid_codes, IDatasetAccessor& collection) const = 0;
/**
* \brief メッシュコードで都市モデルデータをフィルタリングします。
- * \param mesh_codes 欲しい地域IDのvector
+ * \param grid_codes 欲しい地域IDのvector
* \return フィルタリングされた都市モデルデータ
*/
- virtual std::shared_ptr filterByMeshCodes(const std::vector& mesh_codes) const = 0;
+ virtual std::shared_ptr filterByGridCodes(
+ const std::vector>& grid_codes) const = 0;
/**
* \brief 都市モデルデータが存在する地域メッシュのリストを取得します。
*/
- virtual std::set& getMeshCodes() = 0;
+ virtual std::set, GridCodeComparator>& getGridCodes() = 0;
virtual TVec3d calculateCenterPoint(const plateau::geometry::GeoReference& geo_reference) = 0;
diff --git a/include/plateau/dataset/invalid_grid_code.h b/include/plateau/dataset/invalid_grid_code.h
new file mode 100644
index 00000000..1116fa45
--- /dev/null
+++ b/include/plateau/dataset/invalid_grid_code.h
@@ -0,0 +1,58 @@
+#pragma once
+
+#include
+#include "plateau/dataset/grid_code.h"
+#include "plateau/geometry/geo_coordinate.h"
+
+namespace plateau::dataset {
+ /**
+ * \brief 無効なグリッドコードを表すクラスです。
+ *
+ * GridCodeの派生クラスとして、無効なグリッドコードを表現します。
+ * このクラスのインスタンスは常に無効(isValid() == false)です。
+ */
+ class LIBPLATEAU_EXPORT InvalidGridCode : public GridCode {
+ public:
+ InvalidGridCode() = default;
+
+ /**
+ * \brief 無効なグリッドコードを文字列として取得します。
+ * \return 常に空文字列を返します。
+ */
+ std::string get() const override { return ""; }
+
+ /**
+ * \brief 無効なグリッドコードの緯度経度範囲を取得します。
+ * \return 原点(0,0,0)を中心とする無効な範囲を返します。
+ */
+ geometry::Extent getExtent() const override {
+ return {
+ geometry::GeoCoordinate(0, 0, 0),
+ geometry::GeoCoordinate(0, 0, 0)
+ };
+ }
+
+ /**
+ * \brief コードが適切な値かどうかを返します。
+ * \return 常にfalseを返します。
+ */
+ bool isValid() const override { return false; }
+
+ /**
+ * \brief 1段階上のレベルのグリッドコードに変換します。
+ * \return 無効なグリッドコードを返します。
+ */
+ std::shared_ptr upper() const override {
+ return std::make_shared();
+ }
+
+ GridCode* upperRaw() const override {
+ return new InvalidGridCode();
+ }
+
+ int getLevel() const override { return -1; }
+ bool isLargestLevel() const override { return true; }
+ bool isSmallerThanNormalGml() const override { return false; }
+ bool isNormalGmlLevel() const override { return true; }
+ };
+}
\ No newline at end of file
diff --git a/include/plateau/dataset/mesh_code.h b/include/plateau/dataset/mesh_code.h
index 743d5e96..ad9e1cfb 100644
--- a/include/plateau/dataset/mesh_code.h
+++ b/include/plateau/dataset/mesh_code.h
@@ -5,6 +5,7 @@
#include
#include "plateau/geometry/geo_coordinate.h"
+#include "plateau/dataset/grid_code.h"
namespace plateau::dataset {
/**
@@ -12,7 +13,7 @@ namespace plateau::dataset {
*
* 2~5次メッシュの緯度経度範囲の取得、緯度経度範囲を内包する3次メッシュの取得を行う機能を提供しています。
*/
- class LIBPLATEAU_EXPORT MeshCode {
+class LIBPLATEAU_EXPORT MeshCode : public plateau::dataset::GridCode {
public:
explicit MeshCode(const std::string& code);
MeshCode() = default;
@@ -20,17 +21,17 @@ namespace plateau::dataset {
/**
* \brief メッシュコードを文字列として取得します。
*/
- std::string get() const;
+ std::string get() const override;
/**
* \brief メッシュコードの次数を取得します。
*/
- int getLevel() const;
+ int getLevel() const override;
/**
* \brief メッシュコードの緯度経度範囲を取得します。
*/
- geometry::Extent getExtent() const;
+ geometry::Extent getExtent() const override;
/**
* \brief 座標点を含む3次メッシュを取得します。
@@ -47,11 +48,6 @@ namespace plateau::dataset {
*/
static std::shared_ptr> getThirdMeshes(const geometry::Extent& extent);
- /**
- * \brief 地域メッシュが内包されるかどうかを計算します。
- */
- bool isWithin(const MeshCode& other) const;
-
/**
* \brief 地域メッシュを2次メッシュとして取得します。
*/
@@ -60,32 +56,38 @@ namespace plateau::dataset {
/**
* \brief レベル2以上の範囲で1段階上のレベルの地域メッシュに変換します。
*/
- MeshCode& upper();
+ std::shared_ptr upper() const override;
+ GridCode* upperRaw() const override;
/**
* \brief メッシュコードが適切な値かどうかを返します。
*/
- bool isValid() const;
+ bool isValid() const override;
+
+ /**
+ * \brief コードのレベル(詳細度)が、PLATEAUの仕様上考えられる中でもっとも大きいものであるときにtrueを返します。
+ */
+ bool isLargestLevel() const override;
+ bool isSmallerThanNormalGml() const override;
+ bool isNormalGmlLevel() const override;
bool operator==(const MeshCode& other) const;
- //! setに入れるために演算子オーバーロードします。
- bool operator<(MeshCode& other) const;
- bool operator<(const MeshCode& other) const;
+
private:
- int first_row_;
- int first_col_;
- int second_row_;
- int second_col_;
- int third_row_;
- int third_col_;
- int fourth_row_;
- int fourth_col_;
- int fifth_row_;
- int fifth_col_;
- int level_;
- bool is_valid_;
+ int first_row_ = 0;
+ int first_col_ = 0;
+ int second_row_ = 0;
+ int second_col_ = 0;
+ int third_row_ = 0;
+ int third_col_ = 0;
+ int fourth_row_ = 0;
+ int fourth_col_ = 0;
+ int fifth_row_ = 0;
+ int fifth_col_ = 0;
+ int level_ = 0;
+ bool is_valid_ = false;
static void nextRow(MeshCode& mesh_code);
static void nextCol(MeshCode& mesh_code);
diff --git a/include/plateau/dataset/standard_map_grid.h b/include/plateau/dataset/standard_map_grid.h
new file mode 100644
index 00000000..79895230
--- /dev/null
+++ b/include/plateau/dataset/standard_map_grid.h
@@ -0,0 +1,60 @@
+#pragma once
+
+#include
+
+#include
+#include "plateau/geometry/geo_coordinate.h"
+#include "plateau/dataset/grid_code.h"
+
+namespace plateau::dataset {
+ /**
+ * \brief 国土基本図図郭を表します。
+ *
+ * 国土基本図の図郭コードを扱い、緯度経度範囲の取得などの機能を提供します。
+ */
+ class LIBPLATEAU_EXPORT StandardMapGrid : public GridCode {
+ public:
+ explicit StandardMapGrid(std::string code);
+ StandardMapGrid() = default;
+
+ /**
+ * \brief 図郭コードを文字列として取得します。
+ */
+ std::string get() const override;
+
+ /**
+ * \brief 図郭の緯度経度範囲を取得します。
+ */
+ geometry::Extent getExtent() const override;
+
+ /**
+ * \brief 図郭コードが適切な値かどうかを返します。
+ */
+ bool isValid() const override;
+
+ /**
+ * \brief 1段階上のレベルのグリッドコードに変換します。
+ */
+ std::shared_ptr upper() const override;
+ GridCode* upperRaw() const override;
+
+ /**
+ * \brief コードのレベル(詳細度)を取得します。
+ */
+ int getLevel() const override;
+
+ /**
+ * \brief コードのレベル(詳細度)が、PLATEAUの仕様上考えられる中でもっとも大きいものであるときにtrueを返します。
+ */
+ bool isLargestLevel() const override;
+ bool isSmallerThanNormalGml() const override;
+ bool isNormalGmlLevel() const override;
+
+ bool operator==(const StandardMapGrid& other) const;
+ bool operator<(const StandardMapGrid& other) const;
+
+ private:
+ std::string code_; // 図郭コード
+ bool is_valid_ = false; // コードが有効かどうか
+ };
+}
\ No newline at end of file
diff --git a/include/plateau/network/client.h b/include/plateau/network/client.h
index e59f1682..ad5b6010 100644
--- a/include/plateau/network/client.h
+++ b/include/plateau/network/client.h
@@ -1,7 +1,10 @@
#pragma once
#include
#include
-#include
+#include