diff --git a/src/core/model/Anomaly.hpp b/src/core/model/Anomaly.hpp new file mode 100644 index 0000000..b475aeb --- /dev/null +++ b/src/core/model/Anomaly.hpp @@ -0,0 +1,20 @@ +#pragma once +#include +#include +namespace geopro::core { + +enum class AnomalyMarkType { Point = 1, Polyline = 2, Polygon = 3 }; + +struct Vec2 { double x, y; }; + +struct Anomaly { + std::string name; + std::string typeName; // exceptionTypeName + AnomalyMarkType markType = AnomalyMarkType::Polyline; + std::vector localPts; // location.coordinate(局部坐标) + std::string lineColor = "#000000"; // legend.polylineColor + double lineWidth = 1.0; // legend.polylineWidth + bool dashed = true; // legend.polylineShape == "dash" +}; + +} // namespace geopro::core diff --git a/src/core/model/Field.hpp b/src/core/model/Field.hpp index 9c2b534..e7c2a2b 100644 --- a/src/core/model/Field.hpp +++ b/src/core/model/Field.hpp @@ -33,6 +33,10 @@ public: const std::vector& values() const { return values_; } std::vector& values() { return values_; } std::vector x, y; // 轴坐标(规则) + std::vector z; // [nx*ny] 褶皱面抬升(可空=平面) + std::vector elevation; // [nx] 电极/地表高程 + std::vector lat, lon; // [nx] 经纬度 + double vmin = 0.0, vmax = 0.0; private: int nx_, ny_; std::vector values_; @@ -41,6 +45,7 @@ private: // 散点场(剖面原数据):局部坐标 + 值。 struct ScatterField { std::vector x, y, z, v; // 对应样本 xlist/ylist/(hlist)/vlist + std::vector projX, projY; // GIS 平面坐标 }; } // namespace geopro::core diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d296baf..3cacdcb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -26,6 +26,7 @@ target_sources(geopro_tests PRIVATE core/test_model.cpp) target_sources(geopro_tests PRIVATE core/test_color_scale.cpp) target_sources(geopro_tests PRIVATE core/test_idw.cpp) target_sources(geopro_tests PRIVATE core/test_crs_transform.cpp) +target_sources(geopro_tests PRIVATE core/test_model_data.cpp) target_link_libraries(geopro_tests PRIVATE geopro_core) add_subdirectory(spike) # spike S3: banded contour 渲染验证 diff --git a/tests/core/test_model_data.cpp b/tests/core/test_model_data.cpp new file mode 100644 index 0000000..701ae4a --- /dev/null +++ b/tests/core/test_model_data.cpp @@ -0,0 +1,25 @@ +#include +#include "model/Field.hpp" +#include "model/Anomaly.hpp" +using namespace geopro::core; + +TEST(DataModel, GridHasMetaFields) { + Grid g(2, 3); + g.z.assign(6, 0.0); g.elevation = {1,2}; g.lat = {22.5,22.5}; g.lon = {114.1,114.1}; + g.vmin = -10; g.vmax = 800; + EXPECT_EQ(g.z.size(), 6u); + EXPECT_DOUBLE_EQ(g.vmax, 800); +} + +TEST(DataModel, ScatterHasGis) { + ScatterField s; s.projX = {516000.0}; s.projY = {2494000.0}; + EXPECT_EQ(s.projX.size(), 1u); +} + +TEST(DataModel, AnomalyHolds) { + Anomaly a; + a.name = "ERT1-54"; a.markType = AnomalyMarkType::Polyline; + a.localPts = {{1.0, 2.0}, {3.0, 4.0}}; + EXPECT_EQ(a.markType, AnomalyMarkType::Polyline); + EXPECT_EQ(a.localPts.size(), 2u); +}