Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .clangd
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]
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# fbx_sdk は再配布禁止のため、ご自分で用意していただく形になります。
/3rdparty/fbx_sdk/

Expand All @@ -22,8 +21,10 @@ _deps
obj
bin

# Visual Studio
# Editor settings
.vs
.vscode
.idea

# Resharper User config
*.DotSettings.user
Expand Down
2 changes: 0 additions & 2 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions include/plateau/dataset/gml_file.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <libplateau_api.h>
#include <plateau/dataset/mesh_code.h>
#include <set>
#include <optional>
#include "plateau/network/client.h"
Expand All @@ -20,7 +19,8 @@ namespace plateau::dataset {

const std::string& getPath() const;
void setPath(const std::string& path);
MeshCode getMeshCode() const;
std::shared_ptr<GridCode> getGridCode() const;
GridCode* getGridCodeRaw() const; // 寿命管理をDLL利用者に任せる用です
double getEpsg() const;
bool isPolarCoordinateSystem() const;
const std::string& getFeatureType() const;
Expand Down Expand Up @@ -63,7 +63,7 @@ namespace plateau::dataset {

private:
std::string path_;
std::string code_;
std::shared_ptr<GridCode> grid_code_;
std::string feature_type_;
std::string epsg_;
bool is_valid_;
Expand Down
93 changes: 93 additions & 0 deletions include/plateau/dataset/grid_code.h
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();
}
};
}
23 changes: 13 additions & 10 deletions include/plateau/dataset/i_dataset_accessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <libplateau_api.h>
#include <plateau/dataset/gml_file.h>
#include <plateau/dataset/city_model_package.h>
#include <plateau/dataset/grid_code.h>
#include <memory>

namespace plateau::geometry {
class GeoReference;
Expand All @@ -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)) {
}

Expand All @@ -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_;
}

Expand Down Expand Up @@ -93,9 +95,9 @@ namespace plateau::dataset {
* \brief GMLファイル群のうち、範囲が extent の内部であり、パッケージ種が package であるものを vector で返します。
* なお、 package はフラグの集合と見なされるので、複数のビットを立てることで複数の指定が可能です。
*/
virtual std::shared_ptr<std::vector<GmlFile>> getGmlFiles(const PredefinedCityModelPackage package) = 0;
virtual std::shared_ptr<std::vector<GmlFile>> getGmlFiles(PredefinedCityModelPackage package) = 0;

virtual void getGmlFiles(const PredefinedCityModelPackage package,
virtual void getGmlFiles(PredefinedCityModelPackage package,
std::vector<GmlFile>& out_vector) = 0;

/**
Expand All @@ -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<MeshCode>& mesh_codes, IDatasetAccessor& collection) const = 0;
virtual void filterByGridCodes(const std::vector<GridCode*>& grid_codes, IDatasetAccessor& collection) const = 0;

/**
* \brief メッシュコードで都市モデルデータをフィルタリングします。
* \param mesh_codes 欲しい地域IDのvector
* \param grid_codes 欲しい地域IDのvector
* \return フィルタリングされた都市モデルデータ
*/
virtual std::shared_ptr<IDatasetAccessor> filterByMeshCodes(const std::vector<MeshCode>& mesh_codes) const = 0;
virtual std::shared_ptr<IDatasetAccessor> filterByGridCodes(
const std::vector<std::shared_ptr<GridCode>>& grid_codes) const = 0;

/**
* \brief 都市モデルデータが存在する地域メッシュのリストを取得します。
*/
virtual std::set<MeshCode>& getMeshCodes() = 0;
virtual std::set<std::shared_ptr<GridCode>, GridCodeComparator>& getGridCodes() = 0;

virtual TVec3d calculateCenterPoint(const plateau::geometry::GeoReference& geo_reference) = 0;

Expand Down
58 changes: 58 additions & 0 deletions include/plateau/dataset/invalid_grid_code.h
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; }
};
}
Loading
Loading