feat/dataset-detail-chart #5

Merged
gaozheng merged 74 commits from feat/dataset-detail-chart into main 2026-06-13 17:30:37 +08:00
5 changed files with 74 additions and 3 deletions
Showing only changes of commit 3192cf24cf - Show all commits

View File

@ -5,7 +5,8 @@ add_library(geopro_data STATIC
repo/LocalSampleRepository.cpp repo/LocalSampleRepository.cpp
dto/NavDto.cpp dto/NavDto.cpp
dto/DatasetChartDto.cpp dto/DatasetChartDto.cpp
api/ApiProjectRepository.cpp) api/ApiProjectRepository.cpp
api/ApiDatasetRepository.cpp)
target_include_directories(geopro_data PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(geopro_data PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(geopro_data PUBLIC geopro_core geopro_net Qt6::Core PRIVATE nlohmann_json::nlohmann_json) target_link_libraries(geopro_data PUBLIC geopro_core geopro_net Qt6::Core PRIVATE nlohmann_json::nlohmann_json)
target_compile_features(geopro_data PUBLIC cxx_std_17) target_compile_features(geopro_data PUBLIC cxx_std_17)

View File

@ -0,0 +1,51 @@
#include "api/ApiDatasetRepository.hpp"
#include <stdexcept>
#include <QJsonObject>
#include <QString>
#include <QUrl>
#include "ApiClient.hpp"
#include "dto/DatasetChartDto.hpp"
namespace geopro::data {
namespace {
QString enc(const std::string& s) {
return QString::fromUtf8(QUrl::toPercentEncoding(QString::fromStdString(s)));
}
void must(const net::ApiResponse& r, const char* what) {
if (r.code != 200) throw std::runtime_error(std::string(what) + " failed: " +
(r.msg.isEmpty() ? r.rawError.toStdString() : r.msg.toStdString()));
}
geopro::core::ColorScale colorScale(net::ApiClient& api, const std::string& dsId, int type) {
QJsonObject body{{"dsObjectId", QString::fromStdString(dsId)}, {"businessCode", ""}, {"type", type}};
const net::ApiResponse r = api.postJson(QStringLiteral("/business/lvl/colorGradation/getDetail"), body);
must(r, "colorGradation");
return dto::parseColorBar(r.data);
}
} // namespace
ApiDatasetRepository::ApiDatasetRepository(net::ApiClient& api) : api_(api) {}
geopro::core::Grid ApiDatasetRepository::loadGrid(const std::string& dsId) {
const net::ApiResponse r = api_.get(
QStringLiteral("/business/dd/ert/inversion/rows/%1").arg(enc(dsId)));
must(r, "inversion/rows");
return dto::parseInversionGrid(r.data);
}
geopro::core::ScatterField ApiDatasetRepository::loadScatter(const std::string& dsId) {
const net::ApiResponse r = api_.get(
QStringLiteral("/business/dd/ert/inversion/getErtRawDataScatterGraph/%1").arg(enc(dsId)));
must(r, "scatterGraph");
return dto::parseScatterGraph(r.data);
}
geopro::core::ColorScale ApiDatasetRepository::loadColorScale(const std::string& dsId) {
return colorScale(api_, dsId, 2);
}
geopro::core::ColorScale ApiDatasetRepository::loadScatterColorScale(const std::string& dsId) {
return colorScale(api_, dsId, 1);
}
std::vector<geopro::core::Anomaly> ApiDatasetRepository::loadAnomalies(const std::string& dsId) {
const net::ApiResponse r = api_.get(
QStringLiteral("/business/exception/queryException/%1").arg(enc(dsId)));
must(r, "queryException");
return dto::parseDatasetAnomalies(r.data.value(QStringLiteral("value")).toArray());
}
} // namespace geopro::data

View File

@ -0,0 +1,19 @@
#pragma once
#include "repo/IDatasetRepository.hpp"
namespace geopro::net { class ApiClient; }
namespace geopro::data {
// 真实 API 实现 IDatasetRepositoryERT 反演相关)。失败抛 std::runtime_error。
class ApiDatasetRepository : public IDatasetRepository {
public:
explicit ApiDatasetRepository(net::ApiClient& api);
std::vector<GsNode> loadStructure() override { return {}; } // 不经此仓储取结构
geopro::core::Grid loadGrid(const std::string& dsId) override;
geopro::core::ScatterField loadScatter(const std::string& dsId) override;
geopro::core::ColorScale loadColorScale(const std::string& dsId) override; // type2 网格
geopro::core::ColorScale loadScatterColorScale(const std::string& dsId) override; // type1 原数据
std::vector<geopro::core::Anomaly> loadAnomalies(const std::string& dsId) override;
private:
net::ApiClient& api_;
};
} // namespace geopro::data

View File

@ -15,6 +15,7 @@ public:
virtual geopro::core::Grid loadGrid(const std::string& dsId) = 0; virtual geopro::core::Grid loadGrid(const std::string& dsId) = 0;
virtual geopro::core::ScatterField loadScatter(const std::string& dsId) = 0; virtual geopro::core::ScatterField loadScatter(const std::string& dsId) = 0;
virtual geopro::core::ColorScale loadColorScale(const std::string& dsId) = 0; virtual geopro::core::ColorScale loadColorScale(const std::string& dsId) = 0;
virtual geopro::core::ColorScale loadScatterColorScale(const std::string& dsId) = 0;
virtual std::vector<geopro::core::Anomaly> loadAnomalies(const std::string& dsId) = 0; virtual std::vector<geopro::core::Anomaly> loadAnomalies(const std::string& dsId) = 0;
}; };

View File

@ -18,8 +18,7 @@ public:
std::vector<geopro::core::Anomaly> loadAnomalies(const std::string& dsId) override; std::vector<geopro::core::Anomaly> loadAnomalies(const std::string& dsId) override;
// 散点原数据(#17)专属色阶:剖面原数据自带的色阶文件(与网格色阶不同:分段值范围更大)。 // 散点原数据(#17)专属色阶:剖面原数据自带的色阶文件(与网格色阶不同:分段值范围更大)。
// 具体类专有方法(不进 IDatasetRepository 接口)散点点为不透明alpha 量纲差异无影响。 geopro::core::ColorScale loadScatterColorScale(const std::string& dsId) override;
geopro::core::ColorScale loadScatterColorScale(const std::string& dsId);
// DEM/影像 GeoTIFF 的绝对路径(供 render::buildTerrain 经 GDAL 读)。 // DEM/影像 GeoTIFF 的绝对路径(供 render::buildTerrain 经 GDAL 读)。
std::string demPath() const; std::string demPath() const;