mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 13:10:05 +00:00
Add IEM types supporting AFOS list
This commit is contained in:
parent
9f33189c18
commit
cd7435a4d5
3 changed files with 182 additions and 0 deletions
73
wxdata/include/scwx/types/iem_types.hpp
Normal file
73
wxdata/include/scwx/types/iem_types.hpp
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <variant>
|
||||||
|
|
||||||
|
#include <boost/json/value.hpp>
|
||||||
|
|
||||||
|
namespace scwx::types::iem
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief AFOS Entry object
|
||||||
|
*
|
||||||
|
* <https://mesonet.agron.iastate.edu/api/1/docs#/nws/service_nws_afos_list__fmt__get>
|
||||||
|
*/
|
||||||
|
struct AfosEntry
|
||||||
|
{
|
||||||
|
std::int64_t index_ {};
|
||||||
|
std::string entered_ {};
|
||||||
|
std::string pil_ {};
|
||||||
|
std::string productId_ {};
|
||||||
|
std::string cccc_ {};
|
||||||
|
std::int64_t count_ {};
|
||||||
|
std::string link_ {};
|
||||||
|
std::string textLink_ {};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief AFOS List object
|
||||||
|
*
|
||||||
|
* <https://mesonet.agron.iastate.edu/api/1/docs#/nws/service_nws_afos_list__fmt__get>
|
||||||
|
*/
|
||||||
|
struct AfosList
|
||||||
|
{
|
||||||
|
std::vector<AfosEntry> data_ {};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Bad Request (400) object
|
||||||
|
*/
|
||||||
|
struct BadRequest
|
||||||
|
{
|
||||||
|
std::string detail_ {};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Validation Error (422) object
|
||||||
|
*/
|
||||||
|
struct ValidationError
|
||||||
|
{
|
||||||
|
struct Detail
|
||||||
|
{
|
||||||
|
std::string type_ {};
|
||||||
|
std::vector<std::variant<std::int64_t, std::string>> loc_ {};
|
||||||
|
std::string msg_ {};
|
||||||
|
std::string input_ {};
|
||||||
|
struct Context
|
||||||
|
{
|
||||||
|
std::string error_ {};
|
||||||
|
} ctx_;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::vector<Detail> detail_ {};
|
||||||
|
};
|
||||||
|
|
||||||
|
AfosList tag_invoke(boost::json::value_to_tag<AfosList>,
|
||||||
|
const boost::json::value& jv);
|
||||||
|
BadRequest tag_invoke(boost::json::value_to_tag<BadRequest>,
|
||||||
|
const boost::json::value& jv);
|
||||||
|
ValidationError tag_invoke(boost::json::value_to_tag<ValidationError>,
|
||||||
|
const boost::json::value& jv);
|
||||||
|
|
||||||
|
} // namespace scwx::types::iem
|
||||||
103
wxdata/source/scwx/types/iem_types.cpp
Normal file
103
wxdata/source/scwx/types/iem_types.cpp
Normal file
|
|
@ -0,0 +1,103 @@
|
||||||
|
#include <scwx/types/iem_types.hpp>
|
||||||
|
|
||||||
|
#include <boost/json/value_to.hpp>
|
||||||
|
|
||||||
|
namespace scwx::types::iem
|
||||||
|
{
|
||||||
|
|
||||||
|
AfosEntry tag_invoke(boost::json::value_to_tag<AfosEntry>,
|
||||||
|
const boost::json::value& jv)
|
||||||
|
{
|
||||||
|
auto& jo = jv.as_object();
|
||||||
|
|
||||||
|
AfosEntry entry {};
|
||||||
|
|
||||||
|
// Required parameters
|
||||||
|
entry.index_ = jo.at("index").as_int64();
|
||||||
|
entry.entered_ = jo.at("entered").as_string();
|
||||||
|
entry.pil_ = jo.at("pil").as_string();
|
||||||
|
entry.productId_ = jo.at("product_id").as_string();
|
||||||
|
entry.cccc_ = jo.at("cccc").as_string();
|
||||||
|
entry.count_ = jo.at("count").as_int64();
|
||||||
|
entry.link_ = jo.at("link").as_string();
|
||||||
|
entry.textLink_ = jo.at("text_link").as_string();
|
||||||
|
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
AfosList tag_invoke(boost::json::value_to_tag<AfosList>,
|
||||||
|
const boost::json::value& jv)
|
||||||
|
{
|
||||||
|
auto& jo = jv.as_object();
|
||||||
|
|
||||||
|
AfosList list {};
|
||||||
|
|
||||||
|
// Required parameters
|
||||||
|
list.data_ = boost::json::value_to<std::vector<AfosEntry>>(jo.at("data"));
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
BadRequest tag_invoke(boost::json::value_to_tag<BadRequest>,
|
||||||
|
const boost::json::value& jv)
|
||||||
|
{
|
||||||
|
auto& jo = jv.as_object();
|
||||||
|
|
||||||
|
BadRequest badRequest {};
|
||||||
|
|
||||||
|
// Required parameters
|
||||||
|
badRequest.detail_ = jo.at("detail").as_string();
|
||||||
|
|
||||||
|
return badRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
ValidationError::Detail::Context
|
||||||
|
tag_invoke(boost::json::value_to_tag<ValidationError::Detail::Context>,
|
||||||
|
const boost::json::value& jv)
|
||||||
|
{
|
||||||
|
auto& jo = jv.as_object();
|
||||||
|
|
||||||
|
ValidationError::Detail::Context ctx {};
|
||||||
|
|
||||||
|
// Required parameters
|
||||||
|
ctx.error_ = jo.at("error").as_string();
|
||||||
|
|
||||||
|
return ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
ValidationError::Detail
|
||||||
|
tag_invoke(boost::json::value_to_tag<ValidationError::Detail>,
|
||||||
|
const boost::json::value& jv)
|
||||||
|
{
|
||||||
|
auto& jo = jv.as_object();
|
||||||
|
|
||||||
|
ValidationError::Detail detail {};
|
||||||
|
|
||||||
|
// Required parameters
|
||||||
|
detail.type_ = jo.at("type").as_string();
|
||||||
|
detail.loc_ = boost::json::value_to<
|
||||||
|
std::vector<std::variant<std::int64_t, std::string>>>(jo.at("loc"));
|
||||||
|
detail.msg_ = jo.at("msg").as_string();
|
||||||
|
detail.input_ = jo.at("input").as_string();
|
||||||
|
|
||||||
|
detail.ctx_ =
|
||||||
|
boost::json::value_to<ValidationError::Detail::Context>(jo.at("ctx"));
|
||||||
|
|
||||||
|
return detail;
|
||||||
|
}
|
||||||
|
|
||||||
|
ValidationError tag_invoke(boost::json::value_to_tag<ValidationError>,
|
||||||
|
const boost::json::value& jv)
|
||||||
|
{
|
||||||
|
auto& jo = jv.as_object();
|
||||||
|
|
||||||
|
ValidationError error {};
|
||||||
|
|
||||||
|
// Required parameters
|
||||||
|
error.detail_ = boost::json::value_to<std::vector<ValidationError::Detail>>(
|
||||||
|
jo.at("detail"));
|
||||||
|
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace scwx::types::iem
|
||||||
|
|
@ -72,6 +72,8 @@ set(SRC_PROVIDER source/scwx/provider/aws_level2_data_provider.cpp
|
||||||
source/scwx/provider/nexrad_data_provider.cpp
|
source/scwx/provider/nexrad_data_provider.cpp
|
||||||
source/scwx/provider/nexrad_data_provider_factory.cpp
|
source/scwx/provider/nexrad_data_provider_factory.cpp
|
||||||
source/scwx/provider/warnings_provider.cpp)
|
source/scwx/provider/warnings_provider.cpp)
|
||||||
|
set(HDR_TYPES include/scwx/types/iem_types.hpp)
|
||||||
|
set(SRC_TYPES source/scwx/types/iem_types.cpp)
|
||||||
set(HDR_UTIL include/scwx/util/digest.hpp
|
set(HDR_UTIL include/scwx/util/digest.hpp
|
||||||
include/scwx/util/enum.hpp
|
include/scwx/util/enum.hpp
|
||||||
include/scwx/util/environment.hpp
|
include/scwx/util/environment.hpp
|
||||||
|
|
@ -228,6 +230,8 @@ add_library(wxdata OBJECT ${HDR_AWIPS}
|
||||||
${SRC_NETWORK}
|
${SRC_NETWORK}
|
||||||
${HDR_PROVIDER}
|
${HDR_PROVIDER}
|
||||||
${SRC_PROVIDER}
|
${SRC_PROVIDER}
|
||||||
|
${HDR_TYPES}
|
||||||
|
${SRC_TYPES}
|
||||||
${HDR_UTIL}
|
${HDR_UTIL}
|
||||||
${SRC_UTIL}
|
${SRC_UTIL}
|
||||||
${HDR_WSR88D}
|
${HDR_WSR88D}
|
||||||
|
|
@ -248,6 +252,8 @@ source_group("Header Files\\network" FILES ${HDR_NETWORK})
|
||||||
source_group("Source Files\\network" FILES ${SRC_NETWORK})
|
source_group("Source Files\\network" FILES ${SRC_NETWORK})
|
||||||
source_group("Header Files\\provider" FILES ${HDR_PROVIDER})
|
source_group("Header Files\\provider" FILES ${HDR_PROVIDER})
|
||||||
source_group("Source Files\\provider" FILES ${SRC_PROVIDER})
|
source_group("Source Files\\provider" FILES ${SRC_PROVIDER})
|
||||||
|
source_group("Header Files\\types" FILES ${HDR_TYPES})
|
||||||
|
source_group("Source Files\\types" FILES ${SRC_TYPES})
|
||||||
source_group("Header Files\\util" FILES ${HDR_UTIL})
|
source_group("Header Files\\util" FILES ${HDR_UTIL})
|
||||||
source_group("Source Files\\util" FILES ${SRC_UTIL})
|
source_group("Source Files\\util" FILES ${SRC_UTIL})
|
||||||
source_group("Header Files\\wsr88d" FILES ${HDR_WSR88D})
|
source_group("Header Files\\wsr88d" FILES ${HDR_WSR88D})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue