# import < BaiduTraceSDK / BaiduTraceSDK . h > //Start to configure the basic information of the trace service between services BTKServiceOption * basicInfoOption = [ [ BTKServiceOption alloc ] initWithAK : @ "Your AK" mcode : @ "Your bundle id" serviceID : @ "Your serviceID" keepAlive : YES ] ; [ [ BTKAction sharedInstance ] initInfo : basicInfoOption ] ; //Open service BTKStartServiceOption * startServiceOption = [ [ BTKStartServiceOption alloc ] initWithEntityName : @ "entityName" ] ; [ [ BTKAction sharedInstance ] startService : startServiceOption delegate : self ] ; //Stop service [ [ BTKAction sharedInstance ] stopService : self ] ; //Start acquisition [ [ BTKAction sharedInstance ] startGather : self ] ; //End acquisition [ [ BTKAction sharedInstance ] stopGather : self ] ; /** Enable the callback method of the trace service @Param error The result of opening the trace service */ - ( void ) onStartService : ( BTKServiceErrorCode ) error { } /** Callback method for stopping trace service @Param error The result of stopping the trace service */ - ( void ) onStopService : ( BTKServiceErrorCode ) error { } /** Callback method for starting collection @Param error Start collecting operation results */ - ( void ) onStartGather : ( BTKGatherErrorCode ) error { } /** Callback method for stopping collection @Param error Operation result of stopping collection */ - ( void ) onStopGather : ( BTKGatherErrorCode ) error { }
//Set the filter conditions for retrieval BTKQueryEntityFilterOption * filterOption = [ [ BTKQueryEntityFilterOption alloc ] init ] ; filterOption . entityNames = @ [ @ "Test" ] ; filterOption . activeTime = [ [ NSDate date ] timeIntervalSince1970 ] - seven * twenty-four * three thousand and six hundred ; //Set the sorting method of retrieval results BTKSearchEntitySortByOption * sortbyOption = [ [ BTKSearchEntitySortByOption alloc ] init ] ; sortbyOption . fieldName = @ "loc_time" ; sortbyOption . sortType = BTK_ENTITY_SORT_TYPE_DESC ; //Construct the retrieval request object BTKAroundSearchEntityRequest * request = [ [ BTKAroundSearchEntityRequest alloc ] initWithCenter : center inputCoordType : BTK_COORDTYPE_BD09LL radius : one thousand filter : filterOption sortby : sortbyOption outputCoordType : BTK_COORDTYPE_BD09LL pageIndex : one pageSize : ten ServiceID : @ "Your serviceID" tag : @ "Identification of this request" ] ; //Initiate retrieval request [ [ BTKEntityAction sharedInstance ] aroundSearchEntityWith : request delegate : self ] ; #pragma mark - Entity terminal retrieval /** Callback Method for Retrieving Entity Terminal Entity in Circular Area @Param response search results */ - ( void ) onEntityAroundSearch : ( NSData * ) response { dispatch_async ( dispatch_get_main_queue ( ) , ^ { NSDictionary * content = [ NSJSONSerialization JSONObjectWithData : response options : NSJSONReadingMutableContainers error : nil ] ; //Convert Data Format NSLog ( @ Search result:% @ , content ) ; } ) ; }
//Construct request object NSUInteger endTime = [ [ NSDate date ] timeIntervalSince1970 ] ; BTKQueryHistoryTrackRequest * request = [ [ BTKQueryHistoryTrackRequest alloc ] initWithEntityName : @ "entityA" startTime : endTime - eighty-four thousand and four hundred endTime : endTime isProcessed : TRUE processOption : nil supplementMode : BTK_TRACK_PROCESS_OPTION_SUPPLEMENT_MODE_WALKING outputCoordType : BTK_COORDTYPE_BD09LL sortType : BTK_TRACK_SORT_TYPE_DESC pageIndex : one pageSize : ten serviceID : one hundred and three thousand and forty-four tag : thirteen ] ; //Initiate query request [ [ BTKTrackAction sharedInstance ] queryHistoryTrackWith : request delegate : self ] ; /** Callback Method of Track Query @Param response query result */ - ( void ) onQueryHistoryTrack : ( NSData * ) response { //Parse data and plot tracks }
//Set deviation correction options BTKQueryTrackProcessOption * option = [ [ BTKQueryTrackProcessOption alloc ] init ] ; option . denoise = TRUE ; option . mapMatch = TRUE ; option . radiusThreshold = fifteen ; option . transportMode = BTK_TRACK_PROCESS_OPTION_TRANSPORT_MODE_DRIVING ; NSUInteger endTime = [ [ NSDate date ] timeIntervalSince1970 ] ; //Construct request object BTKQueryTrackDistanceRequest * request = [ [ BTKQueryTrackDistanceRequest alloc ] initWithEntityName : @ "entityA" startTime : endTime - eighty-four thousand and four hundred endTime : endTime isProcessed : TRUE processOption : nil supplementMode : BTK_TRACK_PROCESS_OPTION_SUPPLEMENT_MODE_WALkING serviceID : one hundred thousand tag : twelve ] ; //Initiate query request [ [ BTKTrackAction sharedInstance ] queryTrackDistanceWith : request delegate : self ] ;
//Create Fence //Center CLLocationCoordinate2D center = CLLocationCoordinate2DMake ( forty point zero four seven eight , one hundred and sixteen point three one three four ) ; //Construct a new fence object to be created BTKServerCircleFence * fence = [ [ BTKServerCircleFence alloc ] initWithCenter : center radius : fifty coordType : BTK_COORDTYPE_BD09LL denoiseAccuracy : fifty fenceName : @ "server_circle_fence" monitoredObject : @ "entityA" ] ; //Construct request object BTKCreateServerFenceRequest * circleRequest = [ [ BTKCreateServerFenceRequest alloc ] initWithServerCircleFence : fence serviceID : one hundred thousand tag : twenty-one ] ; //Initiate creation request [ [ BTKFenceAction sharedInstance ] createServerFenceWith : circleRequest delegate : self ] ; //Delete fence //Construct request object BTKDeleteServerFenceRequest * request = [ [ BTKDeleteServerFenceRequest alloc ] initWithMonitoredObject : @ "entityA" fenceIDs : nil serviceID : one hundred thousand tag : twenty-two ] ; //Initiate deletion request [ [ BTKFenceAction sharedInstance ] deleteServerFenceWith : request delegate : self ] ; //Real time status query //Build request object BTKQueryServerFenceStatusRequest * request = [ [ BTKQueryServerFenceStatusRequest alloc ] initWithMonitoredObject : @ "entityA" fenceIDs : nil ServiceID : one hundred thousand tag : twenty-five ] ; //Initiate query request [ [ BTKFenceAction sharedInstance ] queryServerFenceStatusWith : request delegate : self ] ;
//Dwell point analysis NSUInteger endTime = [ [ NSDate date ] timeIntervalSince1970 ] ; //Construct request object BTKStayPointAnalysisRequest * request = [ [ BTKStayPointAnalysisRequest alloc ] initWithEntityName : @ "entityA" startTime : endTime - twelve * sixty * sixty endTime : endTime stayTime : one hundred stayRadius : twenty processOption : nil outputCoordType : BTK_COORDTYPE_BD09LL serviceID : one hundred thousand tag : two hundred and twenty-two ] ; //Initiate request [ [ BTKAnalysisAction sharedInstance ] analyzeStayPointWith : request delegate : self ] ; /** Callback method of dwell point analysis @Param response dwell point analysis results */ - ( void ) onAnalyzeStayPoint : ( NSData * ) response { } //Driving behavior analysis NSUInteger endTime = [ [ NSDate date ] timeIntervalSince1970 ] ; //Construct request object BTKDrivingBehaviourAnalysisRequest * request = [ [ BTKDrivingBehaviourAnalysisRequest alloc ] initWithEntityName : @ "zhubei" startTime : endTime - twelve * sixty * sixty endTime : endTime speedingThreshold : fifty processOption : nil outputCoordType : BTK_COORDTYPE_BD09LL serviceID : one hundred and three thousand and forty-four tag : two hundred and twenty-three ] ; //Initiate request [ [ BTKAnalysisAction sharedInstance ] analyzeDrivingBehaviourWith : request delegate : self ] ; /** Callback method of driving behavior analysis @Param response driving behavior analysis results */ - ( void ) onAnalyzeDrivingBehaviour : ( NSData * ) response { }