...
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
#include <chrono>
|
||||
#include <string_view>
|
||||
|
||||
#include "mcc_coord.h"
|
||||
#include "mcc_mount_coord.h"
|
||||
#include "mcc_traits.h"
|
||||
|
||||
namespace mcc
|
||||
@@ -20,9 +20,9 @@ public:
|
||||
typedef std::chrono::duration<double> pz_duration_t;
|
||||
|
||||
struct pz_request_t {
|
||||
bool in_zone{false}; // true if given coordinates are within the zone
|
||||
pz_duration_t time_to; // a time duration to reach the zone
|
||||
pz_duration_t time_from; // a time duration to exit the zone
|
||||
bool in_zone{false}; // true if given coordinates are within the zone
|
||||
pz_duration_t time_to{0.0}; // a time duration to reach the zone
|
||||
pz_duration_t time_from{0.0}; // a time duration to exit the zone
|
||||
};
|
||||
|
||||
struct pz_context_t {
|
||||
@@ -35,19 +35,60 @@ public:
|
||||
return _name;
|
||||
}
|
||||
|
||||
bool inZone(const MccAngle& x,
|
||||
const MccAngle& y,
|
||||
// check if given position (x,y) in the zone
|
||||
template <std::derived_from<MccAngle> XT, std::derived_from<MccAngle> YT>
|
||||
bool inZone(const XT& x,
|
||||
const YT& y,
|
||||
const pz_context_t& context,
|
||||
traits::mcc_systime_c auto const& utc = std::chrono::system_clock::now())
|
||||
{
|
||||
static constexpr size_t coord_kind = traits::mcc_type_pair_hash<XT, YT>();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
pz_request_t request(const MccAngle& x,
|
||||
const MccAngle& y,
|
||||
// returns a time duration to reach the zone
|
||||
// 0 - if already within
|
||||
// Inf - if it never reaches the zone
|
||||
template <std::derived_from<MccAngle> XT, std::derived_from<MccAngle> YT>
|
||||
pz_duration_t timeTo(const XT& x,
|
||||
const YT& y,
|
||||
const pz_context_t& context,
|
||||
traits::mcc_systime_c auto const& utc = std::chrono::system_clock::now())
|
||||
{
|
||||
static constexpr size_t coord_kind = traits::mcc_type_pair_hash<XT, YT>();
|
||||
}
|
||||
|
||||
// returns a time duration to exit from the zone
|
||||
// 0 - if given position (x,y) is out of the zone
|
||||
// Inf - if (x,y) is always within the zone
|
||||
template <std::derived_from<MccAngle> XT, std::derived_from<MccAngle> YT>
|
||||
pz_duration_t timeFrom(const XT& x,
|
||||
const YT& y,
|
||||
const pz_context_t& context,
|
||||
traits::mcc_systime_c auto const& utc = std::chrono::system_clock::now())
|
||||
{
|
||||
static constexpr size_t coord_kind = traits::mcc_type_pair_hash<XT, YT>();
|
||||
}
|
||||
|
||||
|
||||
template <std::derived_from<MccAngle> XT, std::derived_from<MccAngle> YT>
|
||||
pz_request_t request(const XT& x,
|
||||
const YT& y,
|
||||
const pz_context_t& context,
|
||||
traits::mcc_systime_c auto const& utc = std::chrono::system_clock::now())
|
||||
{
|
||||
pz_request_t res{.in_zone = false, .time_to = pz_duration_t{0.0}, .time_from{0.0}};
|
||||
|
||||
res.in_zone = inZone(x, y, context, utc);
|
||||
|
||||
if (res.in_zone) {
|
||||
res.time_from = timeFrom(x, y, context, utc);
|
||||
} else {
|
||||
res.time_to = timeFrom(x, y, context, utc);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
Reference in New Issue
Block a user