Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -(NSArray *)geofencesForLocation:(ProximiioLocation *)location {
  2.     NSMutableArray *geofences = [NSMutableArray array];
  3.     NSArray *allGeofences = [[ProximiioResourceManager sharedManager] allGeofences];
  4.     ProximiioFloor *currentFloor = [[ProximiioLocationManager sharedManager] currentFloor];
  5.     int level = currentFloor.level.intValue;
  6.     NSLog(@"curent level: %d", level);
  7.     for (ProximiioGeofence *geofence in allGeofences) {
  8.         int geofenceLevel = 0;
  9.        
  10.         if (geofence.department && geofence.department.floor) {
  11.             geofenceLevel = geofence.department.floor.level.intValue;
  12.         }
  13.        
  14.         if (geofenceLevel == level) {
  15.             if (geofence.isPolygon) {
  16.                 if ([location isInsidePolygon:geofence.polygon]) {
  17.                     [geofences addObject:geofence];
  18.                 }
  19.             } else {
  20.                 if ([geofence.area distanceFromLocation:location] <= geofence.radius) {
  21.                     [geofences addObject:geofence];
  22.                 }
  23.             }
  24.         }
  25.     }
  26.     return geofences;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement