/*
 *  TnPrefetchRouteData.h
 *  OpenGL Map Engine
 *
 *  Created by Thant on 4/24/2013
 *  Copyright 2013 TeleNav Inc. All rights reserved.
 *
 */

#ifndef TN_PREFETCH_ROUTE_DATA_INCLUDED
#define TN_PREFETCH_ROUTE_DATA_INCLUDED

#include <RenderEngine/ITnMapRouteData.h>

class TnPrefetch;

class TnPrefetchRouteData : public ITnMapRouteData 
{
public:
    /*  To allow us to efficiently specify a location along the route
     *  to start the prefetch, we will use the segment and edge
     *  boundaries.
     */

    typedef std::vector<uint32_t> EdgeIndices;
    typedef std::vector<EdgeIndices> SegmentIndices;
    typedef Tn::Foundation::shared_ptr<SegmentIndices> SegmentIndicesPtr;

    struct Data {
        Data(Tn::math::RoutePtr const & route,
            SegmentIndicesPtr const & segments) :
            route(route), 
            segments(segments) {}

        Tn::math::RoutePtr route;
        SegmentIndicesPtr segments;
    };

    /*  Unlike the actual route proxy, the navigation simulator doesn't
     *  have to preserve the order of the routes. So we just use a
     *  map. 
     */

    typedef std::map<std::string, Data>  RouteMap;
    typedef Tn::Foundation::shared_ptr<RouteMap> RouteMapPtr;
    typedef std::pair<std::string, Data>  RouteMapEntry;

    TnPrefetchRouteData(ITnMapRouteData::ptr const &,
                        Tn::Foundation::shared_ptr<TnPrefetch> const &);

    virtual void NewRoute(std::string const & name, 
                          std::string const & routeStyle, 
                          TnMapArrowParams const & arrowParams);
    
    virtual void NewSegment();
    virtual void NewSegment(TnMapArrowParams const & arrowParams);
    virtual void NewEdge();
    virtual void NewEdge(std::string const & style);
    virtual void AddPoint(double degreesLatitude, 
                          double degreesLongitude,
                          double metersHeight);

    virtual void SetStyle(std::string const & style);

    virtual void SetStart(double degreesLatitude, 
                          double degreesLongitude,
                          double metersHeight);

    virtual void SetFinish(double degreesLatitude, 
                           double degreesLongitude,
                           double metersHeight);

    virtual void SetRequestResult(eTnMapRequestResult result);

private:



    /* The actual info to pass back to the navigation simulator. */

    RouteMapPtr m_routes;

    SegmentIndicesPtr m_segmentIndices;

    /* Current route and indices. */

    Tn::math::RoutePtr m_route;

    ITnMapRouteData::ptr m_data;

    Tn::Foundation::shared_ptr<TnPrefetch> m_prefetch;
};

#endif

