calonso / ios-arkit

iOS Location based Augmented Reality engine
https://github.com/calonso/ios-arkit
MIT License
87 stars 35 forks source link

Distance between pois #9

Open VadimPlasiciuc opened 7 years ago

VadimPlasiciuc commented 7 years ago

Hi i want to implement a function that will receive the distance between pois , and to show all the pois which radius is less that 2km ,and also the radar to setup . The problem that i can't get the idea how to setup it , i want to pass some pois in radius 2km , and one more which range is 2.100km and if i pass the 100meters i want to show the 2.100km poi , and the distanced poi from backside to remove . Could you help me with an idea ? I will be very thankfull 👍

calonso commented 7 years ago

Hi @Stingray1 That sounds cool! Of course I'm happy to help. The way I'd do it is by:

How does it sound? Does it make sense? Please, contribute it back to the project as a Pull Request so that we can keep the engine improving!

Thanks and good luck!

VadimPlasiciuc commented 7 years ago
VadimPlasiciuc commented 7 years ago

Hey i got a problem, i tried for myself adding a locationManager to calculate the distance between him and himself. as for example : location1 = [[CLLocation alloc] initWithLatitude:locationManager.location.coordinate.latitude longitude:locationManager.location.coordinate.longitude ]; ARGeoCoordinate *la = [ARGeoCoordinate coo rdinateWithLocation:location]; la.dataObject = @"Vasile Alexandri"; I've added a button in DetailView.h and he will display on label the distances :

-(void)buttonPressed:(UIButton *) sender {

distance = [locationManager.location distanceFromLocation:location1];
NSLog(@"dISTANCE IS %Lf",distance);
currentDetailView.distsanceLabel.text = [NSString stringWithFormat:@"%Lf",distance];

} and it gives me sometime time the distance correct ,sometimes with a little error . But it also have big error when i get a distance of 40-120meter.

i tried to call the delegate -(void)locationManager:(CLLocationManager )manager didUpdateLocations:(NSArray<CLLocation > *)locations { distance = [locations.lastObject distanceFromLocation:location1]; }

But it didn't help

calonso commented 7 years ago

So about the first comment you were close, but I'd recommend you to look at this other method: locationFound: which is where the LocalizationHelper will notify the engine of a new position. Bascially everytime a new position is registered, distances have to be recomputed based on that new location.

About the second comment I'm not sure I've fully understood. I'd suggest maybe getting rid of the LocalizationHelper and using CLLocationManager instead on the engine as the LocalizationHelper's utilities are all unused in this project. That will maybe make it easier for you to debug.

On the other hand I wouldn't call locationManager:didUpdateLocations directly as that method is intended to be called by the GPS of the device when a new location is found. Also it is worth checking that the age of the location received as well as the accuracies are good enough for your computations, maybe they're causing the error you're experimenting.

Finally I'd suggest you to fork the project and open a PR. That way we can use Github's utilities for code comparing and better communication.

Thanks for your effort!