//
//   DDMASearch.h
//   DDMAMapKit_Private
//   Created by DDIsFriend on 2023/1/30.
    

#import <Foundation/Foundation.h>
#import <AMapSearchKit/AMapSearchKit.h>

NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, MASearchType) {
    kMASearchNone = 1 << 0,
    kMASearchPOIKeywords = 1 << 1,
    kMASearchPOIAround = 1 << 2,
    kMASearchInputTips = 1 << 3,
    kMASearchGeocode = 1 << 4,
    kMASearchReGeocode = 1 << 5,
    kMASearchDrivingCalRoute = 1 << 6,
    kMASearchRidingRoute = 1 << 7,
};
@class AMapSearchObject;

@interface DDMASearch : NSObject
// 申请高德appKey,先设置appKey才能使用search功能
+ (void)startWithAppKey:(nullable NSString *)appKey;

// 创建该类实例前先同意
+ (void)agreePrivacy;

@property (nonatomic, strong)AMapSearchObject *searchOption;

@property (nonatomic, copy)void(^onRequestFailed)(id request,NSError *error);

@property (nonatomic, copy)void(^onResponseDone)(id request,id response);

- (void)refresh;

- (void)loadMore;
@end

typedef NS_ENUM(NSUInteger, MADriveSearchType) {
    kMADriveSearchPolyline,
    kMADriveSearchCost
};
@interface DDMASearch (Route)
typedef NSDictionary *DDMACoordinate NS_TYPED_EXTENSIBLE_ENUM;
typedef NSString *DDMACoordinateKey NS_TYPED_EXTENSIBLE_ENUM;

FOUNDATION_EXTERN DDMACoordinateKey const DDMACoords;// DDMACoordinate[DDMACoords] get coords
FOUNDATION_EXTERN DDMACoordinateKey const DDMACoordsCount; // DDMACoordinate[DDMACoordsCount] get count
FOUNDATION_EXTERN DDMACoordinateKey const DDMALocations;// DDMACoordinate[DDMACoords] get coords

// 返回驾驶的route
+ (AMapSearchObject *)drivingCalRouteSearchRequestWithOrigin:(CLLocationCoordinate2D)origin destination:(CLLocationCoordinate2D)destination strategy:(NSInteger)strategy type:(MADriveSearchType)type;

// 返回骑行的route
+ (AMapSearchObject *)ridingRouteSearchRequestWithOrigin:(CLLocationCoordinate2D)origin destination:(CLLocationCoordinate2D)destination;

// 返回一个包含DDMACoordinate的数组，DDMACoordinate里有coordinates数据和count，利用DDMACoordinateKey去取
+ (NSArray<DDMACoordinate> *)coordsArrayWithRouteSearchResponse:(AMapRouteSearchResponse *)routeSearchResponse;
+ (NSMutableArray<NSMutableArray<CLLocation *> *> *)locationsArrayWithRouteSearchResponse:(AMapRouteSearchResponse *)routeSearchResponse;
@end
NS_ASSUME_NONNULL_END
