配置生成逻辑优化

This commit is contained in:
2026-08-21 17:59:48 +08:00
parent 4909392c5e
commit ff487be64e
19 changed files with 536 additions and 1769 deletions
+4 -7
View File
@@ -185,9 +185,6 @@ class Tile_Path_Resolver {
public:
explicit Tile_Path_Resolver(const Map_Tile_Config& config) :
config_(config), directories_(config.get_true_directories()) {
if (config_.path_layout != "z/x/y" && config_.path_layout != "z/y/x") {
throw std::invalid_argument("invalid tile path_layout: " + config_.path_layout);
}
if (config_.extension.empty() || config_.extension.front() != '.') {
throw std::invalid_argument("invalid tile extension: " + config_.extension);
}
@@ -210,7 +207,7 @@ private:
auto z = std::to_string(request.z);
auto x = std::to_string(request.x);
auto y = std::to_string(request.y) + config_.extension;
if (config_.path_layout == "z/x/y") {
if (config_.path_layout == Map_Tile_Path_Layout::z_x_y) {
return std::filesystem::path(z) / x / y;
}
return std::filesystem::path(z) / std::to_string(request.y) / (std::to_string(request.x) + config_.extension);
@@ -526,7 +523,7 @@ void register_map_graphics_handler() {
return;
}
try {
global->cesium_graphics_config.from_base_json(&parsed.value(), false);
global->cesium_graphics_config.from_base_json(&parsed.value());
Global::save(Config_Section::cesium_graphics);
}
catch (const std::exception& error) {
@@ -675,7 +672,7 @@ void handle_map_model_config_update(const drogon::HttpRequestPtr& req, Global* g
throw std::invalid_argument("invalid map_models");
}
global->map_model_config.write([&](auto& config) {
config.from_base_json(&parsed.value(), false);
config.from_base_json(&parsed.value());
});
Global::save(Config_Section::map_models);
}
@@ -740,7 +737,7 @@ void register_map_view_handler() {
auto next_view = global->map_view_config.read([](const auto& config) {
return config;
});
next_view.from_base_json(&parsed.value(), false);
next_view.from_base_json(&parsed.value());
global->map_resources_config.read([&](const auto& config) {
if (!config.is_imagery_key(next_view.map2d.current_imagery_key) ||
!config.is_imagery_key(next_view.map3d.current_imagery_key)) {