diff --git a/routing/helicopter_router.cpp b/routing/helicopter_router.cpp new file mode 100644 index 0000000000..7cc5ad4a9a --- /dev/null +++ b/routing/helicopter_router.cpp @@ -0,0 +1,21 @@ +#include "helicopter_router.hpp" +#include "route.hpp" + +#include "../base/macros.hpp" + +namespace routing +{ + +void HelicopterRouter::SetFinalPoint(m2::PointD const & finalPt) +{ + m_finalPt = finalPt; +} + +void HelicopterRouter::CalculateRoute(m2::PointD const & startingPt, ReadyCallback const & callback) +{ + m2::PointD points[] = {startingPt, m_finalPt}; + Route route(vector(&points[0], &points[0] + ARRAY_SIZE(points))); + callback(route); +} + +} diff --git a/routing/helicopter_router.hpp b/routing/helicopter_router.hpp new file mode 100644 index 0000000000..d578fc8711 --- /dev/null +++ b/routing/helicopter_router.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include "router.hpp" + +#include "../geometry/point2d.hpp" + +namespace routing +{ + +class HelicopterRouter : public IRouter +{ + m2::PointD m_finalPt; + +public: + virtual string GetName() const { return "helicopter"; } + + virtual void SetFinalPoint(m2::PointD const & finalPt); + virtual void CalculateRoute(m2::PointD const & startingPt, ReadyCallback const & callback); +}; + +} // routing diff --git a/routing/route.cpp b/routing/route.cpp index 1a986d5cf1..51bd28ea6f 100644 --- a/routing/route.cpp +++ b/routing/route.cpp @@ -1 +1,10 @@ #include "route.hpp" + +namespace routing +{ + +Route::Route(vector const & points) : m_poly(points) +{ +} + +} // namespace routing diff --git a/routing/route.hpp b/routing/route.hpp index 402fb0a059..4d94d04bd4 100644 --- a/routing/route.hpp +++ b/routing/route.hpp @@ -1,6 +1,9 @@ #pragma once -#include "../geometry/polyline2d.hpp" +#include "../geometry/polyline2d.hpp" +#include "../geometry/point2d.hpp" + +#include "../std/vector.hpp" namespace routing { @@ -8,6 +11,8 @@ namespace routing class Route { public: + Route(vector const & points); + m2::PolylineD const & GetPoly() const { return m_poly; } private: diff --git a/routing/routing.pro b/routing/routing.pro index 63fe818a83..49b04ff25f 100644 --- a/routing/routing.pro +++ b/routing/routing.pro @@ -11,9 +11,11 @@ SOURCES += \ route.cpp \ routing_engine.cpp \ road_graph.cpp \ + helicopter_router.cpp \ HEADERS += \ route.hpp \ routing_engine.hpp \ router.hpp \ road_graph.hpp \ + helicopter_router.hpp \ diff --git a/routing/routing_engine.cpp b/routing/routing_engine.cpp index 9da1c19cf5..0e23ab34f7 100644 --- a/routing/routing_engine.cpp +++ b/routing/routing_engine.cpp @@ -1,5 +1,6 @@ #include "routing_engine.hpp" #include "route.hpp" +#include "helicopter_router.hpp" #include "../base/stl_add.hpp" @@ -19,7 +20,8 @@ RoutingEngine::~RoutingEngine() void RoutingEngine::AddRouter(string const & name) { - /// @todo + if (!FindRouter(name) && name == "helicopter") + m_routers.push_back(new HelicopterRouter); } void RoutingEngine::RemoveRouter(string const & name)