-
Notifications
You must be signed in to change notification settings - Fork 4
メッシュコードを親クラスのグリッドコードに移行 #270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
96d455a
MeshCodeを親クラスGridCodeに移行中
linoal df78fcf
同上
linoal 8572c2e
GmlFileやDatasetAccessorをMeshCodeからGridCodeに移行
linoal 1870eec
gridCode移行
linoal bd84e7e
GridCode移行2
linoal 18250a5
コード整理
linoal 3922341
Merge remote-tracking branch 'origin/dev/v3' into feature/mesh_code_alt
linoal dc3eab4
テスト修正
linoal 32ab4d3
プルリク指摘に対応
linoal b64d5f7
プルリク指摘に対応2
linoal 5ad9adb
プルリク指摘に対応3
linoal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| #pragma once | ||
|
|
||
| #include <string> | ||
| #include <memory> | ||
| #include <libplateau_api.h> | ||
| #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<GridCode> 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<GridCode> 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<GridCode>& lhs, const std::shared_ptr<GridCode>& 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(); | ||
| } | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #pragma once | ||
|
|
||
| #include <libplateau_api.h> | ||
| #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<GridCode> upper() const override { | ||
| return std::make_shared<InvalidGridCode>(); | ||
| } | ||
|
|
||
| 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; } | ||
| }; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
upperRaw()の生ポインタ戻り値について所有権の所在が不明確なため、生ポインタを返すと呼び出し元が誤って解放しなかったり、二重解放したりする恐れがあります。ライフサイクル管理を明確化するためにも、
unique_ptrなどのスマートポインタを返す設計を検討ください。