
#ifndef TN_MAP_GENERIC_AERIAL_PROXY_H
#define TN_MAP_GENERIC_AERIAL_PROXY_H

#include <foundation/Util/TnPruningMap.h>

#include <RenderEngine/ITnMapRasterTileProxy.h>
#include <RenderEngine/ITnMapResourceProxy.h>
#include <RenderEngine/TnMapResourceData.h>
#include <GenericProxy/TnTileProvider.h>

class TnMapRasterResourceData : public TnMapResourceData
{
public:
	typedef Tn::Foundation::weak_ptr<TnMapRasterResourceData> wptr;
    typedef Tn::Foundation::shared_ptr<TnMapRasterResourceData> ptr;
    
    TnMapRasterResourceData(std::string const & url,
                            TnMapRasterTileData::ptr const & request,
                            std::string const & cacheName);
    
    virtual ~TnMapRasterResourceData();
    
    virtual void SetRequestResult(eTnMapRequestResult result);
    
private:
	
	TnMapRasterTileData::ptr  m_request;
};

class TnGenericRasterTileProxy : public ITnMapRasterTileProxy
{
public:
    typedef Tn::Foundation::shared_ptr<TnGenericRasterTileProxy> ptr;
    
    TnGenericRasterTileProxy(ITnMapResourceProxy::ptr proxy,
                             std::string const & BINGAPIKey);

    // ITnMapRasterTileProxy
    virtual void RequestTile(TnMapRasterTileData::ptr const & data, int zoomBias);
    virtual void CancelRequest(TnMapRasterTileData::ptr const & data);
    
    virtual bool SetTerrainGridResolution(ITnMapEngine::eTerrainGridResolution res);
    
private:
    
    Tn::Foundation::shared_ptr<TnTileProvider> const &
        GetTileProvider(TnMapRasterTileData::eProviderType type);
    
    TnTileProvider::ProviderInfo const GetProviderInfo(TnMapRasterTileData::eProviderType type) const;
    
    //Tile providers in order of TnMapRasterTileData::providerType enums
    typedef std::map<TnMapRasterTileData::eProviderType, Tn::Foundation::shared_ptr<TnTileProvider> > TileProviderMap;
    TileProviderMap m_tileProviders;
	ITnMapResourceProxy::ptr m_resourceProxy;

	TnPruningMap<std::string, ITnMapResourceData::wptr> m_mapRequest;
    
    std::string m_BINGAPIKey;
};

#endif
