airspaces.h 2.59 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
#ifndef AIRMAP_AIRSPACES_H_
#define AIRMAP_AIRSPACES_H_

#include <airmap/airspace.h>
#include <airmap/date_time.h>
#include <airmap/do_not_copy_or_move.h>
#include <airmap/error.h>
#include <airmap/outcome.h>

#include <functional>
#include <vector>

namespace airmap {

/// Airspaces provides functionality to query the airspace database.
class Airspaces : DoNotCopyOrMove {
 public:
  /// ForIds groups together types to ease interaction with
  /// Airspaces::ForIds.
  struct ForIds {
    /// Parameters bundles up input parameters.
    struct Parameters {
      Airspace::Id id;  ///< Search for the airspace with this id.
    };

    /// Result models the outcome of calling Airspaces::for_id.
    using Result = Outcome<std::vector<Airspace>, Error>;
    /// Callback describes the function signature of the callback that is
    /// invoked when a call to Airspaces::for_id finishes.
    using Callback = std::function<void(const Result&)>;
  };

  /// Search groups together types to ease interaction with
  /// Airspaces::Search.
  struct Search {
    /// Parameters bundles up input parameters.
    struct Parameters {
      Optional<Airspace::Type> types;          ///< Search for airspaces with either one of these types.
      Optional<Airspace::Type> ignored_types;  ///< Ignore airspaces with either one of these types.
      Optional<bool> full;  ///< If true, the complete description of airspaces in the result set is requested.
      Geometry geometry;    ///< Search airspaces intersection this geometry.
      Optional<std::uint32_t> buffer;  ///< Buffer around the geometry in [m].
      Optional<std::uint32_t> limit;   ///< Limit the number of results to 'limit'.
      Optional<std::uint32_t> offset;
      Optional<DateTime> date_time;
    };

    /// Result models the outcome of calling Airspaces::search.
    using Result = Outcome<std::vector<Airspace>, Error>;
    /// Callback describes the function signature of the callback that is
    /// invoked when a call to Airspaces::search finishes.
    using Callback = std::function<void(const Result&)>;
  };

  /// search queries the AirMap services for surrounding airspaces and
  /// reports back the results to 'cb'.
  virtual void search(const Search::Parameters& parameters, const Search::Callback& cb) = 0;

  /// for_ids queries the AirMap services for detailed information about
  /// airspaces identified by UUIDs and reports back results to 'cb'.
  virtual void for_ids(const ForIds::Parameters& parameters, const ForIds::Callback& cb) = 0;

 protected:
  /// cond
  Airspaces() = default;
  /// @endcond
};

}  // namespace airmap

#endif  // AIRMAP_AIRSPACES_H_