From 47bc303f0ee970dae1d3b46e4146c7e2aa72608d Mon Sep 17 00:00:00 2001 From: sevendev Date: Tue, 8 Apr 2025 10:44:44 +0900 Subject: [PATCH 01/14] =?UTF-8?q?epsg=E3=81=AB=E3=82=88=E3=82=8B=E5=88=A4?= =?UTF-8?q?=E5=AE=9A=20project=E3=81=AA=E3=81=97=E3=81=AEconvert=E5=87=A6?= =?UTF-8?q?=E7=90=86=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/plateau/dataset/gml_file.h | 3 +++ include/plateau/geometry/geo_coordinate.h | 4 ++-- include/plateau/geometry/geo_reference.h | 5 +++-- src/dataset/gml_file.cpp | 15 +++++++++++++++ src/geometry/geo_reference.cpp | 17 +++++++++++++++++ src/polygon_mesh/mesh_factory.cpp | 5 ++++- src/polygon_mesh/polygon_mesh_utils.cpp | 5 ++++- test/test_gml_file.cpp | 10 ++++++++++ 8 files changed, 58 insertions(+), 6 deletions(-) diff --git a/include/plateau/dataset/gml_file.h b/include/plateau/dataset/gml_file.h index dbf83846..40260877 100644 --- a/include/plateau/dataset/gml_file.h +++ b/include/plateau/dataset/gml_file.h @@ -21,6 +21,8 @@ namespace plateau::dataset { const std::string& getPath() const; void setPath(const std::string& path); MeshCode getMeshCode() const; + double getEpsg() const; + double isPolarCoordinate() const; const std::string& getFeatureType() const; PredefinedCityModelPackage getPackage() const; std::string getAppearanceDirectoryPath() const; @@ -63,6 +65,7 @@ namespace plateau::dataset { std::string path_; std::string code_; std::string feature_type_; + std::string epsg_; bool is_valid_; bool is_local_; int max_lod_; diff --git a/include/plateau/geometry/geo_coordinate.h b/include/plateau/geometry/geo_coordinate.h index 9d0156fe..95095c2e 100644 --- a/include/plateau/geometry/geo_coordinate.h +++ b/include/plateau/geometry/geo_coordinate.h @@ -95,8 +95,8 @@ namespace plateau::geometry { static Extent all() { return { - GeoCoordinate(-90, -180, -9999), - GeoCoordinate(90, 180, 9999) + GeoCoordinate(-9999999, -9999999, -9999), + GeoCoordinate(9999999, 9999999, 9999) }; } }; diff --git a/include/plateau/geometry/geo_reference.h b/include/plateau/geometry/geo_reference.h index fceaab06..52ca6680 100644 --- a/include/plateau/geometry/geo_reference.h +++ b/include/plateau/geometry/geo_reference.h @@ -20,14 +20,15 @@ namespace plateau::geometry { /** * 緯度・経度・高さで表現される座標を平面直角座標系に変換します。 * 座標軸変換を含みます。 - */ + */ TVec3d project(const GeoCoordinate& point) const; TVec3d project(const TVec3d& lat_lon) const; /// project の座標軸変換をしない版です。座標軸は ENU → ENU であるとします。 reference_point_ は ENUに変換されます。 TVec3d projectWithoutAxisConvert(const TVec3d& lat_lon) const; TVec3d convertAxisToENU(const TVec3d& vertex) const; + TVec3d convert(const TVec3d& lat_lon, const bool convert_axis = true, const bool project = true) const; static TVec3d convertAxisFromENUTo(CoordinateSystem axis, const TVec3d& vertex); - static TVec3d convertAxisToENU(CoordinateSystem axis, const TVec3d& vertex); + static TVec3d convertAxisToENU(CoordinateSystem axis, const TVec3d& vertex); GeoCoordinate unproject(const TVec3d& point) const; diff --git a/src/dataset/gml_file.cpp b/src/dataset/gml_file.cpp index 26c238b7..d955e5af 100644 --- a/src/dataset/gml_file.cpp +++ b/src/dataset/gml_file.cpp @@ -51,6 +51,20 @@ namespace plateau::dataset { return MeshCode(code_); } + double GmlFile::getEpsg() const { + return std::stod(epsg_); + } + + double GmlFile::isPolarCoordinate() const { + double epsg = getEpsg(); + // 平面直角座標系の区分についてはこちらを参照してください : + // https://www.mlit.go.jp/plateaudocument/toc9/toc9_08/toc9_08_04/ + if (epsg >= 10162 && epsg <= 10174) { + return false; + } + return true; + } + const std::string& GmlFile::getFeatureType() const { return feature_type_; } @@ -113,6 +127,7 @@ namespace plateau::dataset { try { code_ = filename_parts.empty() ? "" : filename_parts.at(0); feature_type_ = filename_parts.size() <= 1 ? "" : filename_parts.at(1); + epsg_ = filename_parts.empty() ? "" : filename_parts.at(2); is_valid_ = true; } catch (...) { diff --git a/src/geometry/geo_reference.cpp b/src/geometry/geo_reference.cpp index 6bdfe5b5..584c32f8 100644 --- a/src/geometry/geo_reference.cpp +++ b/src/geometry/geo_reference.cpp @@ -24,6 +24,23 @@ namespace plateau::geometry { return converted_point; } + TVec3d GeoReference::convert(const TVec3d& lat_lon, const bool convert_axis, const bool project) const { + //平面直角座標変換、座標軸変換をフラグに応じてスキップします。 + TVec3d point = lat_lon; + // 平面直角座標系に変換 + if (project) + PolarToPlaneCartesian().project(point, zone_id_); + if (!convert_axis) { + // 座標軸変換をしない場合 + TVec3 converted_point = point / unit_scale_ - convertAxisToENU(coordinate_system_, reference_point_); + return converted_point; + } + // 座標軸変換をする場合 + TVec3 converted_point = convertAxisFromENUTo(coordinate_system_, point); + converted_point = converted_point / unit_scale_ - reference_point_; + return converted_point; + } + TVec3d GeoReference::convertAxisToENU(const TVec3d& vertex) const { return convertAxisToENU(getCoordinateSystem(), vertex); } diff --git a/src/polygon_mesh/mesh_factory.cpp b/src/polygon_mesh/mesh_factory.cpp index 93616ee2..34b91bbf 100644 --- a/src/polygon_mesh/mesh_factory.cpp +++ b/src/polygon_mesh/mesh_factory.cpp @@ -9,6 +9,7 @@ #include "plateau/polygon_mesh/mesh_merger.h" #include "plateau/polygon_mesh/mesh_extractor.h" +#include "plateau/dataset/gml_file.h" namespace plateau::polygonMesh { @@ -33,6 +34,8 @@ namespace plateau::polygonMesh { const Polygon& polygon, const std::string& gml_path, const GeoReference& geo_reference, Mesh& out_mesh) { + auto& gml = plateau::dataset::GmlFile(gml_path); + // マージ対象の情報を取得します。ここでの頂点は極座標です。 const auto& vertices_lat_lon = polygon.getVertices(); const auto& in_indices = polygon.getIndices(); @@ -53,7 +56,7 @@ namespace plateau::polygonMesh { auto& out_vertices = out_mesh.getVertices(); out_vertices.reserve(vertices_lat_lon.size()); for (const auto& lat_lon : vertices_lat_lon) { - auto xyz = geo_reference.projectWithoutAxisConvert(lat_lon); + auto xyz = geo_reference.convert(lat_lon, false, gml.isPolarCoordinate()); out_vertices.push_back(xyz); } assert(out_vertices.size() == vertices_lat_lon.size()); diff --git a/src/polygon_mesh/polygon_mesh_utils.cpp b/src/polygon_mesh/polygon_mesh_utils.cpp index 230ec302..2be80743 100644 --- a/src/polygon_mesh/polygon_mesh_utils.cpp +++ b/src/polygon_mesh/polygon_mesh_utils.cpp @@ -2,6 +2,7 @@ #include "plateau/polygon_mesh/mesh.h" #include "plateau/geometry/geo_reference.h" #include "citygml/citymodel.h" +#include namespace plateau::polygonMesh { using namespace citygml; @@ -59,8 +60,10 @@ namespace plateau::polygonMesh { if (!envelope.validBounds()) { return TVec3d{0, 0, 0}; } + auto& gml = plateau::dataset::GmlFile(city_model.getGmlPath()); auto city_center = (envelope.getLowerBound() + envelope.getUpperBound()) / 2.0; - return geometry::GeoReference(coordinate_zone_id).project(city_center); + return geometry::GeoReference(coordinate_zone_id).convert(city_center, true, gml.isPolarCoordinate()); + //return geometry::GeoReference(coordinate_zone_id).project(city_center); } /** diff --git a/test/test_gml_file.cpp b/test/test_gml_file.cpp index c31bef27..b4a5c27e 100644 --- a/test/test_gml_file.cpp +++ b/test/test_gml_file.cpp @@ -13,6 +13,16 @@ namespace plateau::dataset { ASSERT_EQ(PredefinedCityModelPackage::Building, UdxSubFolder::getPackage("bldg")); } + TEST_F(GmlFileTest, get_epsg) { // NOLINT + auto info1 = GmlFile(std::string("foobar/udx/unf/08EE751_unf_10169_water_op.gml")); + ASSERT_EQ(10169, info1.getEpsg()); + ASSERT_FALSE(info1.isPolarCoordinate()); + + auto info2 = GmlFile(std::string("foobar/udx/bldg/53392546_bldg_6697_2_op.gml")); + ASSERT_EQ(6697, info2.getEpsg()); + ASSERT_TRUE(info2.isPolarCoordinate()); + } + // fetch のテストは test_dataset.cpp にあります。 } From 192e66fd94f3447b353bf084044865137371e44a Mon Sep 17 00:00:00 2001 From: sevendev Date: Tue, 8 Apr 2025 10:55:13 +0900 Subject: [PATCH 02/14] geo reference test --- test/CMakeLists.txt | 3 +- test/test_geo_reference.cpp | 79 +++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 test/test_geo_reference.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3efef245..7d6fcc30 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -48,7 +48,8 @@ add_executable(plateau_test "test_texture_image_base.cpp" "test_map_zoom_level_searcher.cpp" "test_height_map_aligner.cpp" - "test_heightmap_mesh_generator.cpp") + "test_heightmap_mesh_generator.cpp" + "test_geo_reference.cpp") add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/test_granularity_convert") diff --git a/test/test_geo_reference.cpp b/test/test_geo_reference.cpp new file mode 100644 index 00000000..2fc400df --- /dev/null +++ b/test/test_geo_reference.cpp @@ -0,0 +1,79 @@ +#include +#include +#include +#include "../src/geometry/polar_to_plane_cartesian.h" + +namespace plateau::geometry { + class GeoReferenceTest : public ::testing::Test { + protected: + void SetUp() override { + } + void TearDown() override { + } + + // テスト設定 + int zone_id = 9; + TVec3d ref_point = TVec3d(0, 0, 0); + float unit_scale = 1.0; + CoordinateSystem coordinate = CoordinateSystem::EUN; + GeoReference ref = GeoReference(zone_id, ref_point, unit_scale, coordinate); + TVec3d base_point = TVec3d(100, 100, 0); + }; + + TEST_F(GeoReferenceTest, ConvertAxisProject) { // NOLINT + + // 平面直角座標変換・座標軸変換を行う + TVec3d converted = ref.convert(base_point, true, true); + TVec3d projected = ref.project(base_point); + + // Expected + TVec3d position = base_point; + PolarToPlaneCartesian().project(position, zone_id); + TVec3 expected_point = GeoReference::convertAxisFromENUTo(coordinate, position); + expected_point = expected_point / unit_scale - ref_point; + + ASSERT_EQ(expected_point, converted); + ASSERT_EQ(expected_point, projected); + } + + TEST_F(GeoReferenceTest, ConvertProjectOnly) { // NOLINT + + // 平面直角座標変換を行う・座標軸変換を行わない + TVec3d converted = ref.convert(base_point, false, true); + TVec3d projected = ref.projectWithoutAxisConvert(base_point); + + // Expected + TVec3d position = base_point; + PolarToPlaneCartesian().project(position, zone_id); + TVec3 expected_point = position / unit_scale - GeoReference::convertAxisToENU(coordinate, ref_point); + + ASSERT_EQ(expected_point, converted); + ASSERT_EQ(expected_point, projected); + } + + TEST_F(GeoReferenceTest, ConvertAxisOnly) { // NOLINT + + // 平面直角座標変換を行わない・座標軸変換を行う + TVec3d point = ref.convert(base_point, true, false); + + // Expected + TVec3 expected_point = GeoReference::convertAxisFromENUTo(coordinate, base_point); + expected_point = expected_point / unit_scale - ref_point; + + ASSERT_EQ(expected_point, point); + } + + TEST_F(GeoReferenceTest, ConvertOnly) { // NOLINT + + // 平面直角座標変換・座標軸変換を行わない + TVec3d point = ref.convert(base_point, false, false); + + // Expected + TVec3 expected_point = base_point / unit_scale - GeoReference::convertAxisToENU(coordinate, ref_point); + + ASSERT_EQ(expected_point, point); + } + + // fetch のテストは test_dataset.cpp にあります。 + +} From c72a8d766e91c58f3df23877a3e36ccabaddfee5 Mon Sep 17 00:00:00 2001 From: sevendev Date: Tue, 8 Apr 2025 11:39:25 +0900 Subject: [PATCH 03/14] mesh extractor unf test --- .../udx/unf/08EE763_unf_10169_sewer_op.gml" | 88 +++++++++++++++++++ test/CMakeLists.txt | 3 +- test/test_mesh_extractor.cpp | 48 ++++++++++ 3 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 "data/\346\227\245\346\234\254\350\252\236\343\203\221\343\202\271\343\203\206\343\202\271\343\203\210/udx/unf/08EE763_unf_10169_sewer_op.gml" diff --git "a/data/\346\227\245\346\234\254\350\252\236\343\203\221\343\202\271\343\203\206\343\202\271\343\203\210/udx/unf/08EE763_unf_10169_sewer_op.gml" "b/data/\346\227\245\346\234\254\350\252\236\343\203\221\343\202\271\343\203\206\343\202\271\343\203\210/udx/unf/08EE763_unf_10169_sewer_op.gml" new file mode 100644 index 00000000..36783690 --- /dev/null +++ "b/data/\346\227\245\346\234\254\350\252\236\343\203\221\343\202\271\343\203\206\343\202\271\343\203\210/udx/unf/08EE763_unf_10169_sewer_op.gml" @@ -0,0 +1,88 @@ + + + + + 156561.10929971817 21007.437699998685 0 + 157517.0072997175 22010.374800001056 225.3813 + + + + + + 雨水マンホール + 2025-03-21 + + + + + + + + + 157110.9434 21547.8443 136.489 157111.4651 21547.5479 136.489 157111.4651 21547.5479 135.139 157110.9434 21547.8443 135.139 157110.9434 21547.8443 136.489 + + + + + + + + + 157111.7615 21548.0695 135.139 157111.4651 21547.5479 135.139 157111.4651 21547.5479 136.489 157111.7615 21548.0695 136.489 157111.7615 21548.0695 135.139 + + + + + + + + + 157111.7615 21548.0695 136.489 157111.4651 21547.5479 136.489 157110.9434 21547.8443 136.489 157111.2398 21548.366 136.489 157111.7615 21548.0695 136.489 + + + + + + + + + 157110.9434 21547.8443 135.139 157111.4651 21547.5479 135.139 157111.7615 21548.0695 135.139 157111.2398 21548.366 135.139 157110.9434 21547.8443 135.139 + + + + + + + + + 157111.2398 21548.366 135.139 157111.7615 21548.0695 135.139 157111.7615 21548.0695 136.489 157111.2398 21548.366 136.489 157111.2398 21548.366 135.139 + + + + + + + + + 157110.9434 21547.8443 135.139 157111.2398 21548.366 135.139 157111.2398 21548.366 136.489 157110.9434 21547.8443 136.489 157110.9434 21547.8443 135.139 + + + + + + + + + + + 500 + 999 + 500 + 999 + 500 + + + 2008 + + + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7d6fcc30..2b7eee80 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -49,7 +49,8 @@ add_executable(plateau_test "test_map_zoom_level_searcher.cpp" "test_height_map_aligner.cpp" "test_heightmap_mesh_generator.cpp" - "test_geo_reference.cpp") + "test_geo_reference.cpp" + ) add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/test_granularity_convert") diff --git a/test/test_mesh_extractor.cpp b/test/test_mesh_extractor.cpp index e0c05d6f..586f2bfb 100644 --- a/test/test_mesh_extractor.cpp +++ b/test/test_mesh_extractor.cpp @@ -8,6 +8,7 @@ #include "../src/polygon_mesh/area_mesh_factory.h" #include #include +#include using namespace citygml; using namespace plateau::geometry; @@ -204,6 +205,53 @@ namespace plateau::polygonMesh { } } + // Epsgが6697以外の場合、平面直角座標変換を行わない + TEST_F(MeshExtractorTest, no_coordinate_transformation_during_conversion) { // NOLINT + + const std::string gml_path = u8"../data/日本語パステスト/udx/unf/08EE763_unf_10169_sewer_op.gml"; + ParserParams params; + MeshExtractOptions mesh_extract_options = MeshExtractOptions(); + params.tesselate = true; + mesh_extract_options.min_lod = 0; + mesh_extract_options.max_lod = 2; + mesh_extract_options.mesh_granularity = MeshGranularity::PerPrimaryFeatureObject; + mesh_extract_options.grid_count_of_side = 5; + mesh_extract_options.exclude_city_object_outside_extent = true; + mesh_extract_options.exclude_polygons_outside_extent = false; + mesh_extract_options.coordinate_zone_id = 8; + mesh_extract_options.mesh_axes = CoordinateSystem::ENU; + const std::shared_ptr city_model = load(gml_path, params); + + auto info = plateau::dataset::GmlFile((city_model->getGmlPath())); + ASSERT_FALSE(info.isPolarCoordinate()); + + auto model = MeshExtractor::extract(*city_model, mesh_extract_options); + const auto& lod_node = model->getRootNodeAt(0); + const auto& first_model_node = lod_node.getChildAt(0); + const auto& mesh = first_model_node.getMesh(); + bool hasVertices = mesh->hasVertices(); + + ASSERT_TRUE(hasVertices); + + const auto& vertices = mesh->getVertices(); + + ASSERT_TRUE(city_model->getRootCityObjects().size() > 0); + + // CityModel Vertex + const auto root_city_object = city_model->getRootCityObjects()[0]; + const auto root_geometry = root_city_object->getGeometry(0).getGeometry(0); + const auto city_model_polygon = root_geometry.getPolygon(0); + const auto city_model_vertices = city_model_polygon->getVertices(); + + for (int i = 0; i < city_model_vertices.size(); i++) { + + const auto& city_model_vertex = city_model_vertices[i]; + const auto& vertex = vertices[i]; + + ASSERT_EQ(vertex, city_model_vertex); + } + } + void MeshExtractorTest::testExtractFromCWrapper() const { const CityModelHandle* city_model_handle; From 26ef26c6ff18307538eeb146a367c9f8b647c648 Mon Sep 17 00:00:00 2001 From: sevendev Date: Tue, 8 Apr 2025 11:58:53 +0900 Subject: [PATCH 04/14] include fix --- test/test_geo_reference.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_geo_reference.cpp b/test/test_geo_reference.cpp index 2fc400df..d07267b0 100644 --- a/test/test_geo_reference.cpp +++ b/test/test_geo_reference.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "../src/geometry/polar_to_plane_cartesian.h" +#include "../src/geometry/polar_to_plane_cartesian.cpp" namespace plateau::geometry { class GeoReferenceTest : public ::testing::Test { From 172783a9d57b3e1a14e06fea4e434d8b74b82ac1 Mon Sep 17 00:00:00 2001 From: sevendev Date: Tue, 8 Apr 2025 12:14:16 +0900 Subject: [PATCH 05/14] code fix --- test/test_geo_reference.cpp | 4 ---- test/test_mesh_extractor.cpp | 6 +++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/test/test_geo_reference.cpp b/test/test_geo_reference.cpp index d07267b0..3b1c81b6 100644 --- a/test/test_geo_reference.cpp +++ b/test/test_geo_reference.cpp @@ -21,7 +21,6 @@ namespace plateau::geometry { }; TEST_F(GeoReferenceTest, ConvertAxisProject) { // NOLINT - // 平面直角座標変換・座標軸変換を行う TVec3d converted = ref.convert(base_point, true, true); TVec3d projected = ref.project(base_point); @@ -37,7 +36,6 @@ namespace plateau::geometry { } TEST_F(GeoReferenceTest, ConvertProjectOnly) { // NOLINT - // 平面直角座標変換を行う・座標軸変換を行わない TVec3d converted = ref.convert(base_point, false, true); TVec3d projected = ref.projectWithoutAxisConvert(base_point); @@ -52,7 +50,6 @@ namespace plateau::geometry { } TEST_F(GeoReferenceTest, ConvertAxisOnly) { // NOLINT - // 平面直角座標変換を行わない・座標軸変換を行う TVec3d point = ref.convert(base_point, true, false); @@ -64,7 +61,6 @@ namespace plateau::geometry { } TEST_F(GeoReferenceTest, ConvertOnly) { // NOLINT - // 平面直角座標変換・座標軸変換を行わない TVec3d point = ref.convert(base_point, false, false); diff --git a/test/test_mesh_extractor.cpp b/test/test_mesh_extractor.cpp index 586f2bfb..06a43c8f 100644 --- a/test/test_mesh_extractor.cpp +++ b/test/test_mesh_extractor.cpp @@ -239,9 +239,9 @@ namespace plateau::polygonMesh { // CityModel Vertex const auto root_city_object = city_model->getRootCityObjects()[0]; - const auto root_geometry = root_city_object->getGeometry(0).getGeometry(0); - const auto city_model_polygon = root_geometry.getPolygon(0); - const auto city_model_vertices = city_model_polygon->getVertices(); + const auto& root_geometry = root_city_object->getGeometry(0).getGeometry(0); + const auto& city_model_polygon = root_geometry.getPolygon(0); + const auto& city_model_vertices = city_model_polygon->getVertices(); for (int i = 0; i < city_model_vertices.size(); i++) { From 2ecc7e2e85b1509521a3a8413c869e1ed09e0cc2 Mon Sep 17 00:00:00 2001 From: sevendev Date: Tue, 8 Apr 2025 15:00:42 +0900 Subject: [PATCH 06/14] unit test code update --- test/test_mesh_extractor.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/test/test_mesh_extractor.cpp b/test/test_mesh_extractor.cpp index 06a43c8f..7840ed50 100644 --- a/test/test_mesh_extractor.cpp +++ b/test/test_mesh_extractor.cpp @@ -205,13 +205,13 @@ namespace plateau::polygonMesh { } } - // Epsgが6697以外の場合、平面直角座標変換を行わない + // Epsgが6697以外(10162~10174)の場合、平面直角座標変換を行わない TEST_F(MeshExtractorTest, no_coordinate_transformation_during_conversion) { // NOLINT const std::string gml_path = u8"../data/日本語パステスト/udx/unf/08EE763_unf_10169_sewer_op.gml"; ParserParams params; - MeshExtractOptions mesh_extract_options = MeshExtractOptions(); params.tesselate = true; + MeshExtractOptions mesh_extract_options = MeshExtractOptions(); mesh_extract_options.min_lod = 0; mesh_extract_options.max_lod = 2; mesh_extract_options.mesh_granularity = MeshGranularity::PerPrimaryFeatureObject; @@ -219,35 +219,32 @@ namespace plateau::polygonMesh { mesh_extract_options.exclude_city_object_outside_extent = true; mesh_extract_options.exclude_polygons_outside_extent = false; mesh_extract_options.coordinate_zone_id = 8; + mesh_extract_options.unit_scale = 1.0; mesh_extract_options.mesh_axes = CoordinateSystem::ENU; const std::shared_ptr city_model = load(gml_path, params); - auto info = plateau::dataset::GmlFile((city_model->getGmlPath())); - ASSERT_FALSE(info.isPolarCoordinate()); + const auto& gml = plateau::dataset::GmlFile((city_model->getGmlPath())); + ASSERT_FALSE(gml.isPolarCoordinate()); auto model = MeshExtractor::extract(*city_model, mesh_extract_options); const auto& lod_node = model->getRootNodeAt(0); const auto& first_model_node = lod_node.getChildAt(0); const auto& mesh = first_model_node.getMesh(); - bool hasVertices = mesh->hasVertices(); - - ASSERT_TRUE(hasVertices); + ASSERT_TRUE(mesh->hasVertices()); const auto& vertices = mesh->getVertices(); + ASSERT_TRUE(vertices.size() > 0); - ASSERT_TRUE(city_model->getRootCityObjects().size() > 0); - - // CityModel Vertex - const auto root_city_object = city_model->getRootCityObjects()[0]; - const auto& root_geometry = root_city_object->getGeometry(0).getGeometry(0); + // CityModel Vertices + const auto& root_city_object = city_model->getRootCityObject(0); + const auto& root_geometry = root_city_object.getGeometry(0).getGeometry(0); const auto& city_model_polygon = root_geometry.getPolygon(0); const auto& city_model_vertices = city_model_polygon->getVertices(); + // 変換されないのでscale:1でENUであればCityModelと座標が同じになる for (int i = 0; i < city_model_vertices.size(); i++) { - const auto& city_model_vertex = city_model_vertices[i]; const auto& vertex = vertices[i]; - ASSERT_EQ(vertex, city_model_vertex); } } From 81a3c63af19c4f95690674d33ab64cf0c36449a1 Mon Sep 17 00:00:00 2001 From: sevendev Date: Tue, 8 Apr 2025 15:11:26 +0900 Subject: [PATCH 07/14] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/polygon_mesh/polygon_mesh_utils.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/polygon_mesh/polygon_mesh_utils.cpp b/src/polygon_mesh/polygon_mesh_utils.cpp index 2be80743..f16199df 100644 --- a/src/polygon_mesh/polygon_mesh_utils.cpp +++ b/src/polygon_mesh/polygon_mesh_utils.cpp @@ -63,7 +63,6 @@ namespace plateau::polygonMesh { auto& gml = plateau::dataset::GmlFile(city_model.getGmlPath()); auto city_center = (envelope.getLowerBound() + envelope.getUpperBound()) / 2.0; return geometry::GeoReference(coordinate_zone_id).convert(city_center, true, gml.isPolarCoordinate()); - //return geometry::GeoReference(coordinate_zone_id).project(city_center); } /** From 3fbb92c3ba392b786786de5140640b3993f63a3a Mon Sep 17 00:00:00 2001 From: sevendev Date: Tue, 8 Apr 2025 15:57:14 +0900 Subject: [PATCH 08/14] mac build error fix --- src/polygon_mesh/mesh_factory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/polygon_mesh/mesh_factory.cpp b/src/polygon_mesh/mesh_factory.cpp index 34b91bbf..962db5a1 100644 --- a/src/polygon_mesh/mesh_factory.cpp +++ b/src/polygon_mesh/mesh_factory.cpp @@ -34,7 +34,7 @@ namespace plateau::polygonMesh { const Polygon& polygon, const std::string& gml_path, const GeoReference& geo_reference, Mesh& out_mesh) { - auto& gml = plateau::dataset::GmlFile(gml_path); + const auto& gml = plateau::dataset::GmlFile(gml_path); // マージ対象の情報を取得します。ここでの頂点は極座標です。 const auto& vertices_lat_lon = polygon.getVertices(); From b699c7e1889e9b9acc9c79b34c04f6d5375bc5a6 Mon Sep 17 00:00:00 2001 From: sevendev Date: Tue, 8 Apr 2025 16:09:03 +0900 Subject: [PATCH 09/14] =?UTF-8?q?=E3=82=B3=E3=83=A1=E3=83=B3=E3=83=88?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=20build=20error=20=E4=BF=AE=E6=AD=A3=20?= =?UTF-8?q?=E4=BE=8B=E5=A4=96=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/plateau/geometry/geo_coordinate.h | 3 +-- src/dataset/gml_file.cpp | 7 ++++++- src/polygon_mesh/polygon_mesh_utils.cpp | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/plateau/geometry/geo_coordinate.h b/include/plateau/geometry/geo_coordinate.h index 95095c2e..1dc4cf7b 100644 --- a/include/plateau/geometry/geo_coordinate.h +++ b/include/plateau/geometry/geo_coordinate.h @@ -16,8 +16,7 @@ namespace plateau::geometry { * EPSGコードが 6697 のとき、それは * 「日本測地系2011における経緯度座標系と東京湾平均海面を基準とする標高の複合座標参照系」 * になります。 - * TODO - * EPSGコードの判別と、それによって処理を変える機能は未実装です。 + * EPSGコードが 10162 ~ 10174 の場合は平面直角座標系となります。 */ struct GeoCoordinate { double latitude; diff --git a/src/dataset/gml_file.cpp b/src/dataset/gml_file.cpp index d955e5af..dbebae6e 100644 --- a/src/dataset/gml_file.cpp +++ b/src/dataset/gml_file.cpp @@ -52,7 +52,12 @@ namespace plateau::dataset { } double GmlFile::getEpsg() const { - return std::stod(epsg_); + try { + return epsg_.empty() ? 6697 : std::stod(epsg_); + } + catch (const std::exception&) { + return 6697; + } } double GmlFile::isPolarCoordinate() const { diff --git a/src/polygon_mesh/polygon_mesh_utils.cpp b/src/polygon_mesh/polygon_mesh_utils.cpp index f16199df..70999e47 100644 --- a/src/polygon_mesh/polygon_mesh_utils.cpp +++ b/src/polygon_mesh/polygon_mesh_utils.cpp @@ -60,7 +60,7 @@ namespace plateau::polygonMesh { if (!envelope.validBounds()) { return TVec3d{0, 0, 0}; } - auto& gml = plateau::dataset::GmlFile(city_model.getGmlPath()); + const auto& gml = plateau::dataset::GmlFile(city_model.getGmlPath()); auto city_center = (envelope.getLowerBound() + envelope.getUpperBound()) / 2.0; return geometry::GeoReference(coordinate_zone_id).convert(city_center, true, gml.isPolarCoordinate()); } From 2a9d14a146df78f745bd7970be81e7b356424346 Mon Sep 17 00:00:00 2001 From: sevendev Date: Tue, 8 Apr 2025 16:18:14 +0900 Subject: [PATCH 10/14] refactoring : isPolarCoordinate -> usePolarConversion --- include/plateau/dataset/gml_file.h | 2 +- src/dataset/gml_file.cpp | 2 +- src/polygon_mesh/mesh_factory.cpp | 2 +- src/polygon_mesh/polygon_mesh_utils.cpp | 2 +- test/test_gml_file.cpp | 4 ++-- test/test_mesh_extractor.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/plateau/dataset/gml_file.h b/include/plateau/dataset/gml_file.h index 40260877..037f4495 100644 --- a/include/plateau/dataset/gml_file.h +++ b/include/plateau/dataset/gml_file.h @@ -22,7 +22,7 @@ namespace plateau::dataset { void setPath(const std::string& path); MeshCode getMeshCode() const; double getEpsg() const; - double isPolarCoordinate() const; + double usePolarConversion() const; const std::string& getFeatureType() const; PredefinedCityModelPackage getPackage() const; std::string getAppearanceDirectoryPath() const; diff --git a/src/dataset/gml_file.cpp b/src/dataset/gml_file.cpp index dbebae6e..95e34942 100644 --- a/src/dataset/gml_file.cpp +++ b/src/dataset/gml_file.cpp @@ -60,7 +60,7 @@ namespace plateau::dataset { } } - double GmlFile::isPolarCoordinate() const { + double GmlFile::usePolarConversion() const { double epsg = getEpsg(); // 平面直角座標系の区分についてはこちらを参照してください : // https://www.mlit.go.jp/plateaudocument/toc9/toc9_08/toc9_08_04/ diff --git a/src/polygon_mesh/mesh_factory.cpp b/src/polygon_mesh/mesh_factory.cpp index 962db5a1..8bf34365 100644 --- a/src/polygon_mesh/mesh_factory.cpp +++ b/src/polygon_mesh/mesh_factory.cpp @@ -56,7 +56,7 @@ namespace plateau::polygonMesh { auto& out_vertices = out_mesh.getVertices(); out_vertices.reserve(vertices_lat_lon.size()); for (const auto& lat_lon : vertices_lat_lon) { - auto xyz = geo_reference.convert(lat_lon, false, gml.isPolarCoordinate()); + auto xyz = geo_reference.convert(lat_lon, false, gml.usePolarConversion()); out_vertices.push_back(xyz); } assert(out_vertices.size() == vertices_lat_lon.size()); diff --git a/src/polygon_mesh/polygon_mesh_utils.cpp b/src/polygon_mesh/polygon_mesh_utils.cpp index 70999e47..5683d8f5 100644 --- a/src/polygon_mesh/polygon_mesh_utils.cpp +++ b/src/polygon_mesh/polygon_mesh_utils.cpp @@ -62,7 +62,7 @@ namespace plateau::polygonMesh { } const auto& gml = plateau::dataset::GmlFile(city_model.getGmlPath()); auto city_center = (envelope.getLowerBound() + envelope.getUpperBound()) / 2.0; - return geometry::GeoReference(coordinate_zone_id).convert(city_center, true, gml.isPolarCoordinate()); + return geometry::GeoReference(coordinate_zone_id).convert(city_center, true, gml.usePolarConversion()); } /** diff --git a/test/test_gml_file.cpp b/test/test_gml_file.cpp index b4a5c27e..4ee8857c 100644 --- a/test/test_gml_file.cpp +++ b/test/test_gml_file.cpp @@ -16,11 +16,11 @@ namespace plateau::dataset { TEST_F(GmlFileTest, get_epsg) { // NOLINT auto info1 = GmlFile(std::string("foobar/udx/unf/08EE751_unf_10169_water_op.gml")); ASSERT_EQ(10169, info1.getEpsg()); - ASSERT_FALSE(info1.isPolarCoordinate()); + ASSERT_FALSE(info1.usePolarConversion()); auto info2 = GmlFile(std::string("foobar/udx/bldg/53392546_bldg_6697_2_op.gml")); ASSERT_EQ(6697, info2.getEpsg()); - ASSERT_TRUE(info2.isPolarCoordinate()); + ASSERT_TRUE(info2.usePolarConversion()); } // fetch のテストは test_dataset.cpp にあります。 diff --git a/test/test_mesh_extractor.cpp b/test/test_mesh_extractor.cpp index 7840ed50..c34a5560 100644 --- a/test/test_mesh_extractor.cpp +++ b/test/test_mesh_extractor.cpp @@ -224,7 +224,7 @@ namespace plateau::polygonMesh { const std::shared_ptr city_model = load(gml_path, params); const auto& gml = plateau::dataset::GmlFile((city_model->getGmlPath())); - ASSERT_FALSE(gml.isPolarCoordinate()); + ASSERT_FALSE(gml.usePolarConversion()); auto model = MeshExtractor::extract(*city_model, mesh_extract_options); const auto& lod_node = model->getRootNodeAt(0); From ca0ef488a1c6ce37afa5b64c442d182402509fdc Mon Sep 17 00:00:00 2001 From: sevendev Date: Tue, 8 Apr 2025 16:28:20 +0900 Subject: [PATCH 11/14] =?UTF-8?q?bool=20isPolarCoordinateSystem()=20?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/plateau/dataset/gml_file.h | 2 +- src/dataset/gml_file.cpp | 2 +- src/polygon_mesh/mesh_factory.cpp | 2 +- src/polygon_mesh/polygon_mesh_utils.cpp | 2 +- test/test_gml_file.cpp | 4 ++-- test/test_mesh_extractor.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/plateau/dataset/gml_file.h b/include/plateau/dataset/gml_file.h index 037f4495..e9954d30 100644 --- a/include/plateau/dataset/gml_file.h +++ b/include/plateau/dataset/gml_file.h @@ -22,7 +22,7 @@ namespace plateau::dataset { void setPath(const std::string& path); MeshCode getMeshCode() const; double getEpsg() const; - double usePolarConversion() const; + bool isPolarCoordinateSystem() const; const std::string& getFeatureType() const; PredefinedCityModelPackage getPackage() const; std::string getAppearanceDirectoryPath() const; diff --git a/src/dataset/gml_file.cpp b/src/dataset/gml_file.cpp index 95e34942..e1eca097 100644 --- a/src/dataset/gml_file.cpp +++ b/src/dataset/gml_file.cpp @@ -60,7 +60,7 @@ namespace plateau::dataset { } } - double GmlFile::usePolarConversion() const { + bool GmlFile::isPolarCoordinateSystem() const { double epsg = getEpsg(); // 平面直角座標系の区分についてはこちらを参照してください : // https://www.mlit.go.jp/plateaudocument/toc9/toc9_08/toc9_08_04/ diff --git a/src/polygon_mesh/mesh_factory.cpp b/src/polygon_mesh/mesh_factory.cpp index 8bf34365..f03579fd 100644 --- a/src/polygon_mesh/mesh_factory.cpp +++ b/src/polygon_mesh/mesh_factory.cpp @@ -56,7 +56,7 @@ namespace plateau::polygonMesh { auto& out_vertices = out_mesh.getVertices(); out_vertices.reserve(vertices_lat_lon.size()); for (const auto& lat_lon : vertices_lat_lon) { - auto xyz = geo_reference.convert(lat_lon, false, gml.usePolarConversion()); + auto xyz = geo_reference.convert(lat_lon, false, gml.isPolarCoordinateSystem()); out_vertices.push_back(xyz); } assert(out_vertices.size() == vertices_lat_lon.size()); diff --git a/src/polygon_mesh/polygon_mesh_utils.cpp b/src/polygon_mesh/polygon_mesh_utils.cpp index 5683d8f5..4ff9f853 100644 --- a/src/polygon_mesh/polygon_mesh_utils.cpp +++ b/src/polygon_mesh/polygon_mesh_utils.cpp @@ -62,7 +62,7 @@ namespace plateau::polygonMesh { } const auto& gml = plateau::dataset::GmlFile(city_model.getGmlPath()); auto city_center = (envelope.getLowerBound() + envelope.getUpperBound()) / 2.0; - return geometry::GeoReference(coordinate_zone_id).convert(city_center, true, gml.usePolarConversion()); + return geometry::GeoReference(coordinate_zone_id).convert(city_center, true, gml.isPolarCoordinateSystem()); } /** diff --git a/test/test_gml_file.cpp b/test/test_gml_file.cpp index 4ee8857c..1acb51a1 100644 --- a/test/test_gml_file.cpp +++ b/test/test_gml_file.cpp @@ -16,11 +16,11 @@ namespace plateau::dataset { TEST_F(GmlFileTest, get_epsg) { // NOLINT auto info1 = GmlFile(std::string("foobar/udx/unf/08EE751_unf_10169_water_op.gml")); ASSERT_EQ(10169, info1.getEpsg()); - ASSERT_FALSE(info1.usePolarConversion()); + ASSERT_FALSE(info1.isPolarCoordinateSystem()); auto info2 = GmlFile(std::string("foobar/udx/bldg/53392546_bldg_6697_2_op.gml")); ASSERT_EQ(6697, info2.getEpsg()); - ASSERT_TRUE(info2.usePolarConversion()); + ASSERT_TRUE(info2.isPolarCoordinateSystem()); } // fetch のテストは test_dataset.cpp にあります。 diff --git a/test/test_mesh_extractor.cpp b/test/test_mesh_extractor.cpp index c34a5560..2dad32aa 100644 --- a/test/test_mesh_extractor.cpp +++ b/test/test_mesh_extractor.cpp @@ -224,7 +224,7 @@ namespace plateau::polygonMesh { const std::shared_ptr city_model = load(gml_path, params); const auto& gml = plateau::dataset::GmlFile((city_model->getGmlPath())); - ASSERT_FALSE(gml.usePolarConversion()); + ASSERT_FALSE(gml.isPolarCoordinateSystem()); auto model = MeshExtractor::extract(*city_model, mesh_extract_options); const auto& lod_node = model->getRootNodeAt(0); From f226f0583d97ba129c98d5102a578a4d67546a3c Mon Sep 17 00:00:00 2001 From: sevendev Date: Tue, 8 Apr 2025 16:32:58 +0900 Subject: [PATCH 12/14] C# unit test fix --- .../CSharpPLATEAU.Test/Dataset/DatasetAccessorTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrappers/csharp/LibPLATEAU.NET/CSharpPLATEAU.Test/Dataset/DatasetAccessorTest.cs b/wrappers/csharp/LibPLATEAU.NET/CSharpPLATEAU.Test/Dataset/DatasetAccessorTest.cs index 9523495b..4a429e2f 100644 --- a/wrappers/csharp/LibPLATEAU.NET/CSharpPLATEAU.Test/Dataset/DatasetAccessorTest.cs +++ b/wrappers/csharp/LibPLATEAU.NET/CSharpPLATEAU.Test/Dataset/DatasetAccessorTest.cs @@ -66,7 +66,7 @@ public void GetPackagesLocal() using var datasetSource = DatasetSource.Create(new DatasetSourceConfigLocal(TestDataPathLocal)); using var accessor = datasetSource.Accessor; Console.WriteLine(Path.GetFullPath(accessor.GetGmlFiles(PredefinedCityModelPackage.Building).At(0).Path)); - var expected = PredefinedCityModelPackage.Building | PredefinedCityModelPackage.Road; + var expected = PredefinedCityModelPackage.Building | PredefinedCityModelPackage.Road | PredefinedCityModelPackage.UndergroundFacility; Assert.AreEqual(expected, accessor.Packages); } From 758c6c43b9dba382031dac57efeb740d3d03005a Mon Sep 17 00:00:00 2001 From: sevendev Date: Tue, 8 Apr 2025 16:36:55 +0900 Subject: [PATCH 13/14] =?UTF-8?q?=E3=82=BF=E3=83=96=E3=81=AE=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dataset/gml_file.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dataset/gml_file.cpp b/src/dataset/gml_file.cpp index e1eca097..d5f23478 100644 --- a/src/dataset/gml_file.cpp +++ b/src/dataset/gml_file.cpp @@ -65,8 +65,8 @@ namespace plateau::dataset { // 平面直角座標系の区分についてはこちらを参照してください : // https://www.mlit.go.jp/plateaudocument/toc9/toc9_08/toc9_08_04/ if (epsg >= 10162 && epsg <= 10174) { - return false; - } + return false; + } return true; } From 721f421a032eb68593e167d2d142e2716324d554 Mon Sep 17 00:00:00 2001 From: sevendev Date: Tue, 8 Apr 2025 16:59:12 +0900 Subject: [PATCH 14/14] =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E5=90=8D=E3=81=AE=E3=83=91=E3=83=BC=E3=82=B9=E5=87=A6=E7=90=86?= =?UTF-8?q?=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dataset/gml_file.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dataset/gml_file.cpp b/src/dataset/gml_file.cpp index d5f23478..5549fa00 100644 --- a/src/dataset/gml_file.cpp +++ b/src/dataset/gml_file.cpp @@ -132,7 +132,7 @@ namespace plateau::dataset { try { code_ = filename_parts.empty() ? "" : filename_parts.at(0); feature_type_ = filename_parts.size() <= 1 ? "" : filename_parts.at(1); - epsg_ = filename_parts.empty() ? "" : filename_parts.at(2); + epsg_ = filename_parts.size() <= 2 ? "" : filename_parts.at(2); is_valid_ = true; } catch (...) {