//
//  TnMapEngine.h
//  TelenavNavigator
//
//  Created by Ryan Drake on 2/1/11.
//  Copyright (c) 2011 Telenav, Inc. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>

#include <RenderEngine/ITnMapEngine.h>
#include <GenericProxy/TnGenericProxyFactoryTSI.h>

#import "TMKEngineTypes.h"
#import "TMKTouchDelegate.h"
#import "TnAnnotationDetails.h"

@interface TnMapEngine : NSObject

@property ITnMapEngine::ptr mapEngineImpl;
@property BOOL buildThreadExit;
@property BOOL buildThreadPaused;
@property NSCondition* buildThreadCondition;
@property NSThread* buildThread;

- (id)initWithMapTileBaseURL:(NSString*)mapTileBaseURL andTrafficTileBaseURL:(NSString*)trafficTileBaseURL andLandmarkTileBaseURL:(NSString*)landmarkTileBaseURL withMapTileParameter:(NSString*)mapTileParameter withTrafficTileParameter:(NSString*)trafficTileParameter;

- (id)initWithMapTileBaseURL:(NSString*)mapTileBaseURL andTrafficTileBaseURL:(NSString*)trafficTileBaseURL andLandmarkTileBaseURL:(NSString*)landmarkTileBaseURL withMapTileParameter:(NSString*)mapTileParameter withTrafficTileParameter:(NSString*)trafficTileParameter andEngineConfig:(NSString*)engineConfig;


- (void)setBuildingInterval:(NSTimeInterval)duration;

// For use by View
- (void)draw:(ITnMapEngine::ViewId)viewId delta:(CFTimeInterval)delta;
// Touch handling
- (void)setTouchModeForView:(ITnMapEngine::ViewId)viewId mode:(TMKTouchMode)touchMode;
- (void)handleTouchEventForView:(ITnMapEngine::ViewId)viewId event:(TMKTouchEvent)event point:(CGPoint)p;
- (void)handleTouchEventForView:(ITnMapEngine::ViewId)viewId event:(TMKTouchEvent)event point1:(CGPoint)p1 point2:(CGPoint)p2;

// For use by ViewController
- (void)setPaused:(BOOL)pause; //pauses/starts build thread

// View controls
- (void)setVerticalOffset:(double)offset forView:(ITnMapEngine::ViewId)viewId; //offset within frame
- (void)setHorizontalOffset:(double)offset forView:(ITnMapEngine::ViewId)viewId; //offset within frame

+ (float)toTelenavZoomLevel:(float)normalZoomLevel;
+ (float)toNormalZoomLevel:(float)telenavZoomLevel;
- (void)setZoom:(float)zoomLevel forView:(ITnMapEngine::ViewId)viewId; // set current zoom level (from 0-17)
- (float)zoomForView:(ITnMapEngine::ViewId)viewId;

// Set rendering behavior
- (BOOL)setRenderMode:(TMKRenderMode)renderMode forView:(ITnMapEngine::ViewId)viewId; //set rendering mode (2D vs 3D, Heading up, North up, etc...)


//labels from this list will not be displayed (current street for example)
- (void)setNoDrawStringList:(NSArray*)stringList forView:(ITnMapEngine::ViewId)viewId;

//sets the traffic proxy units
-(void)setTrafficEnglishUnits:(BOOL)enable;

// Query
- (CLLocation*)getLocationForScreenPoint:(CGPoint)point inView:(ITnMapEngine::ViewId)viewId;

// configuration loading
- (BOOL)loadConfiguration:(NSString*)config intoConfig:(ITnMapEngine::ConfId)configId;
- (BOOL)loadConfigurations:(NSArray*)configs intoConfig:(ITnMapEngine::ConfId)configId;
- (BOOL)loadConfiguration:(NSString*)config intoConfig:(ITnMapEngine::ConfId)configId andNotify:(ITnMapEngine::ViewId)viewId;
- (BOOL)loadConfigurations:(NSArray*)configs intoConfig:(ITnMapEngine::ConfId)configId andNotify:(ITnMapEngine::ViewId)viewId;

// Tap the engine, reports touched annotations through delegate
- (TMKAnnotationPopup*)tap:(CGPoint)point withLongPress:(BOOL)longPress
                 andDelegate:(id<TMKTouchDelegate>)touchDelegate
                     withDPI:(float)dpi
             annotationIdMap:(AnnotationIdMap&)annotationIds
                     forView:(ITnMapEngine::ViewId)viewId;

// ADI location
- (void)setADIWithNearestLocation:(CLLocation*)location forView:(ITnMapEngine::ViewId)viewId;

@property (nonatomic, assign) BOOL bIsForTvOut;

@end
