Finish windowed load. Not all polygon updates are shown on the map.

This commit is contained in:
Dan Paulat 2025-04-16 23:29:40 -05:00
parent 33e18765b7
commit 1a1c668d62
3 changed files with 65 additions and 62 deletions

View file

@ -1,12 +1,16 @@
#pragma once
#include <scwx/awips/text_product_file.hpp>
#include <scwx/network/cpr.hpp>
#include <scwx/types/iem_types.hpp>
#include <memory>
#include <ranges>
#include <string>
#include <vector>
#include <boost/outcome/result.hpp>
#include <cpr/cpr.h>
#if defined(_MSC_VER)
# pragma warning(push)
@ -47,12 +51,41 @@ public:
ranges::any_view<std::string_view> ccccs = {},
ranges::any_view<std::string_view> pils = {});
template<std::ranges::forward_range Range>
requires std::same_as<std::ranges::range_value_t<Range>, std::string>
static std::vector<std::shared_ptr<awips::TextProductFile>>
LoadTextProducts(const std::vector<std::string>& textProducts);
LoadTextProducts(const Range& textProducts)
{
auto parameters = cpr::Parameters {{"nolimit", "true"}};
std::vector<std::pair<std::string, cpr::AsyncResponse>> asyncResponses {};
asyncResponses.reserve(textProducts.size());
const std::string endpointUrl = kBaseUrl_ + kNwsTextProductEndpoint_;
for (const auto& productId : textProducts)
{
asyncResponses.emplace_back(
productId,
cpr::GetAsync(cpr::Url {endpointUrl + productId},
network::cpr::GetHeader(),
parameters));
}
return ProcessTextProductResponses(asyncResponses);
}
private:
class Impl;
std::unique_ptr<Impl> p;
static const std::string kBaseUrl_;
static const std::string kListNwsTextProductsEndpoint_;
static const std::string kNwsTextProductEndpoint_;
static std::vector<std::shared_ptr<awips::TextProductFile>>
ProcessTextProductResponses(
std::vector<std::pair<std::string, cpr::AsyncResponse>>& asyncResponses);
};
} // namespace scwx::provider