Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Radar like LOVOO app with slider

I am working on an app which has a functionality of RADAR just like LOVOO app. I don't have experience of working on CoreLocation and other location based frameworks.

It would be much appreciated if you could suggest me how should this can be achieved. What frameworks should i use and how to proceed initially.

Though same question already exists on SO over here my question is same as Radar View like LOVOO but its of no use to me thats why i am asking it again.

What i have tried myself so far is, i have lat and long values of points to plot and i have calculated angle and distance between centre point(my location) and other point

- (float)angletoCoordinate:(CLLocationCoordinate2D)second {

//myCurrentLocation is origin

//second is point

float lat1 = DegreesToRadians(myCurrentLocation.coordinate.latitude);
float lon1 = DegreesToRadians(myCurrentLocation.coordinate.longitude);

float lat2 = DegreesToRadians(second.latitude);
float lon2 = DegreesToRadians(second.longitude);

float dLon = lon2 - lon1;

float y = sin(dLon) * cos(lat2);
float x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dLon);
float radiansBearing = atan2(y, x);
if(radiansBearing < 0.0)
{
    radiansBearing += 2*M_PI;
}

return radiansBearing;
}


-(float)calculateXPointWithLoc:(ARGeoLocation *)loc andDelta:(float)delta{
float angle = radiansToDegrees(delta);
float dpx = (([myCurrentLocation distanceFromLocation:loc.geoLocation])/1000);

if(0<=angle<=90)
    return viewRadar.center.x + sin(angle)*dpx ;
else if(90<angle<=180)
    return viewRadar.center.x + cos(angle-90)*dpx  ;
else if(180<angle<=270)
    return viewRadar.center.x - cos(270-angle)*dpx ;
else if(270<angle<360)
    return viewRadar.center.x - sin(360-angle)*dpx ;

return 0;
}

-(float)calculateYPointWithLoc:(ARGeoLocation *)loc andDelta:(float)delta{
float angle = radiansToDegrees(delta);

float dpx = (([myCurrentLocation distanceFromLocation:loc.geoLocation])/1000);



if(0<=angle<=90)
    return viewRadar.center.y - cos(angle)*dpx ;
else if(90<angle<=180)
    return viewRadar.center.y + sin(angle-90)*dpx ;
else if(180<angle<=270)
    return viewRadar.center.y + sin(270-angle)*dpx ;
else if(270<angle<360)
    return viewRadar.center.y - cos(360-angle)*dpx ;

return 0;
}

and then

    int i = 0;
    for(ARGeoLocation *loc in coordinates){

    deltaAz = [self angletoCoordinate:loc.geoLocation.coordinate];
    x = [self calculateXPointWithLoc:loc andDelta:deltaAz];
    y = [self calculateYPointWithLoc:loc andDelta:deltaAz];

    [[plots objectAtIndex:i] setFrame:CGRectMake(x, y, DIAMETER_PLOT, DIAMETER_PLOT)];
    i++;
    }

I am not sure whether x and y are correct or not also if they are correct then how can i change these value with change of slider value.

like image 337
Pankaj Wadhwa Avatar asked Nov 05 '14 06:11

Pankaj Wadhwa


1 Answers

I think the keyword here is Geofencing.

Geofencing is the automatic triggering of an action if your device enters or leaves a certain region. For your case your action is to display the profiles of those users who enter the area of your radar.

Basically you need to calculate a circular region (given a radius) and display all other points within your region.

I once found this tutorial which could teach how to do it by yourself: http://www.raywenderlich.com/95014/geofencing-ios-swift

I hope it helps!

like image 78
Gerald Avatar answered Sep 23 '22 19:09

Gerald