Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distance between pois #9

Open
VadimPlasiciuc opened this issue Feb 21, 2017 · 4 comments
Open

Distance between pois #9

VadimPlasiciuc opened this issue Feb 21, 2017 · 4 comments

Comments

@VadimPlasiciuc
Copy link

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
Copy link
Owner

calonso commented Feb 22, 2017

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

  • Add a new maximum_distance configuration parameter that holds the maximum distance from the observer that you want POIs to appear. Think about a way of 'disabling' this feature should other user not want to filter POIs out based on that distance.
  • Then we can either reuse the viewportContainsCoordinate method or even better, create a new method that will decide wether a POI has to appear or not based on its coordinate's radialDistance to the observer. That new method should be invoked by the engine when it is positioning views
  • The radar bit shouldn't be hard either. We'll probably need to pass that maximum_distance parameter upon initialisation somehow and then, when it is updating points add a check so that only points whose radialDistance is smaller than the limit appear.

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
Copy link
Author

  • (void)addCoordinate:(ARGeoCoordinate *)coordinate {
    [ar_coordinates addObject:coordinate];

    if (coordinate.radialDistance > maximumScaleDistance) {
    maximumScaleDistance = coordinate.radialDistance;
    }

    //message the delegate.
    ARObjectView * ob = [delegate viewForCoordinate:coordinate floorLooking:NO];
    ob.controller = self;
    [ar_coordinateViews addObject:ob];

    if (showsFloorImages) {
    ARObjectView *floor = [delegate viewForCoordinate:coordinate floorLooking:YES];
    floor.controller = self;
    [ar_floorCoordinateViews addObject:floor];
    }

    [coordinate calibrateUsingOrigin:centerCoordinate.geoLocation useAltitude:useAltitude];
    if (coordinate.radialDistance > maximumScaleDistance) {
    maximumScaleDistance = coordinate.radialDistance;
    radar.farthest = maximumScaleDistance;
    }
    }

  • (void)addCoordinates:(NSArray *)newCoordinates {
    for (ARGeoCoordinate *coordinate in newCoordinates) {
    [self addCoordinate:coordinate];
    }
    }
    i studied this method , but i got a question, how do i get the locationManager position for observer through "LocalizationHelper ? "

@VadimPlasiciuc
Copy link
Author

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
Copy link
Owner

calonso commented Feb 22, 2017

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants