Loading location from cloud with Indoor SDK doesn't work

Hey,

I’ve tried to load a location from the estimote cloud in my App with this example http://developer.estimote.com/indoor/build-an-app/ , but it doesn’t work. It seems like the cloud connection is fine and the location is although found. However I get two errors ‘can’t fetch location:’ and ‘failed to update position:’… Where is my mistake?

This is my code (I’ve imported ESTConfig.h and ESTIndoorLocationManager.h)

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    self.locationManager = [ESTIndoorLocationManager new];
    self.locationManager.delegate = self;
    
    
    
    [ESTConfig setupAppID:@"%%%%%%" andAppToken:@"%%%%%%%%%"];
    
    
    [self.locationManager fetchLocationByIdentifier:@"%%%%" withSuccess:^(id object) {
        self.location = object;
    } failure:^(NSError *error) {
        NSLog(@"can't fetch location: %@", error);
    }];
    
    [self.locationManager startIndoorLocation:self.location];
    

}

-    (void)indoorLocationManager:(ESTIndoorLocationManager *)manager
didFailToUpdatePositionWithError:(NSError *)error {
    NSLog(@"failed to update position: %@", error);
}

- (void)indoorLocationManager:(ESTIndoorLocationManager *)manager
            didUpdatePosition:(ESTOrientedPoint *)position
                 withAccuracy:(ESTPositionAccuracy)positionAccuracy
                   inLocation:(ESTLocation *)location {
    NSString *accuracy;
    switch (positionAccuracy) {
        case ESTPositionAccuracyVeryHigh: accuracy = @"+/- 1.00m"; break;
        case ESTPositionAccuracyHigh:     accuracy = @"+/- 1.62m"; break;
        case ESTPositionAccuracyMedium:   accuracy = @"+/- 2.62m"; break;
        case ESTPositionAccuracyLow:      accuracy = @"+/- 4.24m"; break;
        case ESTPositionAccuracyVeryLow:  accuracy = @"+/- ? :-("; break;
    }
    NSLog(@"x: %5.2f, y: %5.2f, orientation: %3.0f, accuracy: %@",
          position.x, position.y, position.orientation, accuracy);
}

Thanks,
Elli

What’s the full error message for “can’t fetch location”?

Sorry, I was a confused… I get no “fetch location error”, my error is : ‘failed to update position: Error Domain=com.estimote Code=1 “Can’t determine position outside the location.” UserInfo=XXXXX {NSLocalizedDescription=Can’t determine position outside the location.}’… but I’m always in this location. Thank you!

And if you go to the Indoor app (from the App Store), and to the same location that you’re fetching in your own app, does it also say that you’re outside the location?

It works fine with Indoor App

In the “success” block of the “fetchLocationByIdentifier,” can you add:

self.location = object;
// add this:
NSLog(@"location: %@", [self.location toDictionary]);

… and post the result here?

The result looks great:

IndoorLocation Example[483:310793] location: {
    beacons =     (
                {
            beacon =             {
                color = 0;
                mac = e890ca81eed2;
            };
            position =             {
                orientation = "92.53438544523109";
                x = "0.100030531324262";
                y = "-2.00844934672392";
            };
        },
                {
            beacon =             {
                color = 0;
                mac = fc4f494b90df;
            };
            position =             {
                orientation = "2.71567161147358";
                x = "-0.260081065159139";
                y = "-1.62843273811697";
            };
        },
                {
            beacon =             {
                color = 0;
                mac = f7525e53fdd5;
            };
            position =             {
                orientation = "93.0274224532279";
                x = "-1.29235779974645";
                y = "0.897818011655473";
            };
        },
                {
            beacon =             {
                color = 0;
                mac = f9ffca44997f;
            };
            position =             {
                orientation = "159.596203656939";
                x = "-0.860341555212758";
                y = "1.58045364556424";
            };
        },
                {
            beacon =             {
                color = 0;
                mac = c9d74ff51150;
            };
            position =             {
                orientation = "3.02742245322784";
                x = "0.379600356119242";
                y = "-2.40414501573982";
            };
        },
                {
            beacon =             {
                color = 0;
                mac = f293d85a71fe;
            };
            position =             {
                orientation = "159.596203656939";
                x = "-0.860341555212758";

                y = "1.58045364556424";
            };
        },
                {
            beacon =             {
                color = 0;
                mac = cb0582b7a0dc;
            };
            position =             {
                orientation = "274.952178588765";
                x = "1.26556617648223";
                y = "1.46389215318612";
            };
        },
                {
            beacon =             {
                color = 0;
                mac = e6dc8b7ac9ec;
            };
            position =             {
                orientation = "274.952178588765";
                x = "1.07267008802567";
                y = "-0.762319268179166";
            };
        }
    );
    "created_at" = "2015-09-18T13:56:31.441Z";
    identifier = "inabe-mit-ecke-";
    "linear_objects" =     (
                {
            orientation = "3.02742245322784";
            type = 0;
            x1 = "0.764394657906969";
            x2 = "0.8380603164256279";
            y1 = "-2.42449590826076";
            y2 = "-2.42839191683478";
        }
    );
    name = "Inabe mit Ecke ";
    orientation = 0;
    version = "0.3";
    walls =     (
                {
            orientation = "274.952178588765";
            x1 = "0.92789704745649";
            x2 = "1.34680340030029";
            y1 = "-2.43314317653158";
            y2 = "2.40144996968122";
        },
                {
            orientation = "159.596203656939";
            x1 = "1.34680340030029";
            x2 = "-1.26419976242892";
            y1 = "2.40144996968122";
            y2 = "1.43022966378147";
        },
                {
            orientation = "93.0274224532279";
            x1 = "-1.26419976242892";
            x2 = "-1.4230479952002";
            y1 = "1.43022966378147";
            y2 = "-1.57326980222643";
        },
                {
            orientation = "2.71567161147358";
            x1 = "-1.4230479952002";
            x2 = "0.116061212188212";
            y1 = "-1.57326980222643";
            y2 = "-1.64627427066192";
        },
                {
            orientation = "92.53438544523109";
            x1 = "0.116061212188212";
            x2 = "0.08320998267545281";
            y1 = "-1.64627427066192";
            y2 = "-2.38846960525122";
        },
                {
            orientation = "3.02742245322784";
            x1 = "0.08320998267545281";
            x2 = "0.92789704745649";
            y1 = "-2.38846960525122";
            y2 = "-2.43314317653158";
        }
    );
}

but then:
IndoorLocation Example[483:310793] failed to update position: Error Domain=com.estimote Code=1 “Can’t determine position outside the location.” UserInfo=XXXX {NSLocalizedDescription=Can’t determine position outside the location.}

I’ve solved my problem , it was a simple mistake . The line
[self.locationManager startIndoorLocation:self.location]; was just in the wrong position.

Nevertheless many thanks!

1 Like

Ah, of course, now I see that too (:

Some better error handling (in this case: starting location updates when the location hasn’t been fetched yet) needed on our side, thanks for spotting that!