PDA

View Full Version : iOS: limitations for [detectedPOIs enumerateObjectsUsingBlock...] and startPOITrackin



Ivaylo
17.12.2014, 15:12
Hi,

i have currently the problem that not every POI configured in my code is being tracked.
Here some code



static int const kRadius = 5000;//meters
static float const kRefreshMargin = 0.1;
static int const kTrackablePOITypeIncident = 1000;

- (void)poiTracker:(SKPOITracker *)poiTracker didDectectPOIs:(NSArray *)detectedPOIs withType:(int)type
{
// NSLog(@"didDectectPOIs");
[detectedPOIs enumerateObjectsUsingBlock:^(SKDetectedPOI *detectedPOI, NSUInteger index, BOOL *stop){
[[SKRoutingService sharedInstance] clearAllRoutesFromCache];
NSLog(@"Start");
NSLog(@"Detected: %@",[detectedPOI description]);
NSLog(@"poiID: %d",[detectedPOI poiID]);
NSLog(@"Distance: %d",[detectedPOI distance]);

if ([detectedPOI poiID] == 1 && [detectedPOI distance] <= 100 && Poi1Played == 0) {
[self->audioPlayer stop];
if (audioPlayer.isPlaying) {
// player is playing
} else {
[self playSound:@"UXRUN_01_Tatort"];
}
Poi1Played = 1;
}
if ([detectedPOI poiID] == 1 && [detectedPOI distance] <= 20) {
SKRouteSettings* route = [[SKRouteSettings alloc]init];
if (Simulation) {
route.startCoordinate=CLLocationCoordinate2DMake(P oi1Lat, Poi1Long);
} else {
route.startCoordinate=CLLocationCoordinate2DMake(s elf.locationManager.location.coordinate.latitude, self.locationManager.location.coordinate.longitude );
}
route.destinationCoordinate=CLLocationCoordinate2D Make(Dec1Lat, Dec1Long);
route.shouldBeRendered = YES; // If NO, the route will not be rendered.
route.requestAdvices = YES;
route.numberOfRoutes = 1;
route.routeMode = SKRoutePedestrian;
route.requestExtendedRoutePointsInfo = YES;
[[SKRoutingService sharedInstance] calculateRoute:route];
// NSLog(@"POI 1 L÷wentor in 20m");
}
}];
}

-(void)startPOITracking
{
SKTrackablePOIRule *rule = [SKTrackablePOIRule trackablePOIRule];
rule.routeDistance = 1500; //1500
rule.aerialDistance = 150; //3000

self.poiTracker = [[SKPOITracker alloc]init];
self.poiTracker.dataSource = self;
self.poiTracker.delegate = self;
[self.poiTracker startPOITrackerWithRadius:kRadius refreshMargin:kRefreshMargin forPOITypes:@[@(kTrackablePOITypeIncident)]];;
[self.poiTracker setRule:rule forPOIType:kTrackablePOITypeIncident];
NSLog(@"didDectectPOIs in startPOITracking");
}


In my use case I track about 20 different POI with this command: "if ([detectedPOI poiID] == 1 && [detectedPOI distance] <= 20) { "
The problem here is that not every POI is tracked.
In the Logging Output Window in Xcode i see the logging informations but for some POI the tracker don't reach the <= 20 meter.
50 meters before the tracker moves to the next POI the next POI is been triggered.
Is there a limitation for this function?
The distance between the POI is about 300 to 500 meters.
I did some changes in the constant rule.aerialDistance

Thank you very much for the help,
Ivaylo

dandronic
17.12.2014, 15:35
Hi Ivaylo - we'll look into it

Ivaylo
18.12.2014, 12:52
Hello,

here two screenshots from the iOS simulator:
Everything seems to be ok:
1720
poi: 2
distance: 54

A couple of meters further a new route is calculated (I don't know why?!) and poi 2 don't reach less than 10 meter. The counter stops at distance: 54
1721

When I position the coordinate at some point before this error happens, everything works fine. But I need to place the point just before the crossing.

Here are the lat ling coordinates:
49.878591, 8.667068 - here the poi should be placed, but this don't work as expected
49.877703, 8.667258 - here everything works as expected, but the point is set to early

Adela_Silvia
06.01.2015, 15:52
Hi Ivaylo,

The problem might be caused by the fact that the same poiID is used for all the POIs. You have to add a unique identifier(poiID) for each POI. Please make this change and let us know if this solves the issue.