/*
 *  TnProtoBufVectorData.h
 *
 *  Created by Thant on July 15, 2013.
 *  Copyright 2013 TeleNav. All rights reserved.
 *
 */

#ifndef TN_PROTOBUF_VECTOR_DATA_H
#define TN_PROTOBUF_VECTOR_DATA_H

#include <foundation/SharedPtr.h>
#include <foundation/WeakPtr.h>

#include <foundation/TnTypes.h>
#include <foundation/Init.hpp>

#include <RenderEngine/TnMapVectorData.h>

#include <GenericProxy/ITnVDProtoBufData.h>

class TnProtoBufToVectorData : public ITnVDProtoBufData
{
public:

    virtual void SetVectorData(ProtoBufPtr const &);
    virtual void SetRequestResult(eTnMapRequestResult);

    virtual TnMapTileId const & GetTileId() const;

    TnProtoBufToVectorData(TnMapVectorData::ptr const &);

    // To be called by the Init object only.
    static void InitDecoder(bool);

private:

    TnMapVectorData::ptr m_data;
    ProtoBufPtr m_protoBuf;
    TnMapTileId m_tileId;

    // Decoder machinery (copied with minor modifications from

    static void Decode(ProtoBufPtr const & from, TnMapVectorData::ptr const & to);

    //Called by InitDecoder
    static void BuildIconStyleMap();
    static void BuildCityIconMap();
    static void BuildPolygonBuildingMap();
    static void BuildRailStyleMap();
    static void BuildBorderMap();
    
    static std::string const RoadTypeToEdge(com::telenav::proto::map::RoadType type, com::telenav::proto::map::RoadSubType subtype);
    static std::string const RoadTypeTo2dLabel(com::telenav::proto::map::RoadType type);
    static std::string const RoadTypeTo3dLabel(com::telenav::proto::map::RoadType type);
    static std::string const AreaTypeToPolygon(com::telenav::proto::map::AreaType type,  std::string const & strSubType);
    static std::string const LineTypeToEdge(com::telenav::proto::map::LineType type, std::string& strSubType);
    static std::string const PoiTypeTo2dLabel(com::telenav::proto::map::PointFeature const & pointFeature);
    static std::string  PoiTypeTo3dLabel(com::telenav::proto::map::PointFeature const & pointFeature);
    static std::string  RoadIconStyleName(std::string const & name, std::string const & country, std::string const & subType);
    static std::string const & PoiIconStyleName(std::string const & subType);
    static std::string const & CityTypeToLabelStyle(std::string const & subtype);
    
    typedef std::pair<std::string, std::string> PoiIconStylePair;
    typedef std::map<std::string,  std::string> PoiIconStyleMap;
    
    static PoiIconStyleMap* s_PoiIconStyleMap;
    static PoiIconStyleMap* s_PoiCityIconMap;
    
    static PoiIconStyleMap* s_PolygonBuildingTypeMap;
    static PoiIconStyleMap* s_RailStyleMap;
    static PoiIconStyleMap* s_BorderStyleMap;

};


namespace {

::Tn::Foundation::Init TnProtoBufToVectorDataDecoderInit(&TnProtoBufToVectorData::InitDecoder);

} // namespace


#endif
