Location not found : PositionFailureException and CachedPosition

4 views
Skip to first unread message

Mishit

unread,
Aug 21, 2010, 3:22:03 PM8/21/10
to Location Labs Developer Community
Hello
1) I am getting PositionFailureException intermittently (70-80%)
though my phone has good reception.
2) Also response content has the cached location but unable to access
the it.
e.getCachedLocation() is returning null in this case.

catch (PositionFailureException e) {
System.out.println(e.getMessage());
if(e.getCachedLocation() != null)
{ loc = e.getCachedLocation();
buf.append(" <p>Cached Location");
buf.append(" <p>Longitude: " + loc.getLongitude() + "</
p>");
buf.append(" <p>Latitude: " + loc.getLatitude() + "</
p>");
}

Response snippet
-----------------------------------
10/08/21 14:19:10 2010/08/21 14:19:10:377 EDT [DEBUG] header - <<
"Content-Length: 353[\r][\n]"
10/08/21 14:19:10 2010/08/21 14:19:10:377 EDT [DEBUG] header - <<
"Content-Type: application/json;charset=ISO-8859-1[\r][\n]"
10/08/21 14:19:10 2010/08/21 14:19:10:377 EDT [DEBUG] header - << "[\r]
[\n]"
10/08/21 14:19:10 2010/08/21 14:19:10:377 EDT [DEBUG] HttpMethodBase -
Cookie accepted: "$Version=0;
JSESSIONID=23A0EEB805A0D53A33DA794D6C0B14B6; $Path=/"
10/08/21 14:19:10 2010/08/21 14:19:10:377 EDT [DEBUG] HttpMethodBase -
Buffering response body
10/08/21 14:19:10 2010/08/21 14:19:10:377 EDT [DEBUG] content - <<
"{"location":{"id":
9134446829463732202,"created":"2010-08-21T18:13:46Z","expires":"2010-08-22T18:13:46Z","positionError":
{"code":100,"message":"Location was not available.","cachedPosition":
{"longitude":-84.336896,"latitude":33.937602,"uncertainty":
18.0,"address":
{"street":"Street","city":"Atlanta","state":"GA","postal":"30338","countryCode":"USA"}}}}}"
10/08/21 14:19:10 2010/08/21 14:19:10:378 EDT [DEBUG] HttpMethodBase -
Resorting to protocol version default close connection policy
10/08/21 14:19:10 2010/08/21 14:19:10:378 EDT [DEBUG] HttpMethodBase -
Should NOT close connection, using HTTP/1.1

Eli Bishop

unread,
Aug 25, 2010, 1:25:24 PM8/25/10
to veriplace-deve...@googlegroups.com

On Sat, 2010-08-21 at 12:22 -0700, Mishit wrote:
> Hello
> 1) I am getting PositionFailureException intermittently (70-80%)
> though my phone has good reception.

Hmm. By "good reception" do you mean that you're able to get GPS
location on the phone with other applications - or just that you have
good signal bars for a voice connection? It's certainly possible for a
phone to have good cell signal strength, but not be locatable,
especially if it's indoors. In many cases we can fall back to less
accurate cell-tower-triangulation positioning, but not always; this
depends on the carrier. If you email the phone number to me directly, I
can take a look at our carrier logs to see if something else is going
on.


> 2) Also response content has the cached location but unable to access
> the it.
> e.getCachedLocation() is returning null in this case.

Assuming that the response snippet below is really from the same request
that gave you the null cachedLocation... that's weird. It's possible
that there's a bug in our JSON parsing for this data type, which might
not have been detected earlier since most people are using XML; but
there's a unit test specifically for this, and at first glance the test
document looks just like this to me. I'll try putting your response
data through the test code to make sure. However, if it's possible that
this data was actually from a different request, bear in mind that not
every failed request is going to provide a cached location - it depends
on how long ago the last successful locate was.

best,
Eli

--
Eli Bishop
Wavemarket, Inc. / Location Labs
e...@location-labs.com

Mishit

unread,
Sep 14, 2010, 11:36:11 AM9/14/10
to Location Labs Developer Community

Hello Eli
Please see my response as below :

On Aug 25, 1:25 pm, Eli Bishop <e...@wavemarket.com> wrote:
1)
> Hmm.  By "good reception" do you mean that you're able to get GPS
> location on the phone with other applications - or just that you have....

Yeah when I say "good reception" I mean I have good signal bars for
voice/data connection.
I didn't see whether GPS is available or not. But when I got the same
error again I went back and checked the google maps app on my phone
and yes it couldn't locate my GPS
accurately. I have sent you that mobile number in separate email.
By the way I am under impression that Location Labs only uses cell
tower positioning and it has nothing to do with GPS.

> > 2)
> Assuming that the response snippet below is really from the same request
> that gave you the null cachedLocation... that's weird.

Yes. For above response snippet I am still getting null
cachedLocation.
Can you please confirm if JSON parsing has any bug with this ?

thanks
/Mishit

Eli Bishop

unread,
Sep 14, 2010, 7:48:39 PM9/14/10
to Location Labs Developer Community
Mishit,

Well, I have answers for a few things, although a few others are still
mysterious.

1.
First, the reason you sometimes get a PositionFailureException, even
though I've verified that the phone is definitely locatable and has
been reporting valid locations:

What is happening is that you're using Freedom mode for your location
requests (I don't know if you're specifying that mode explicitly, but
it is the default if you don't specify a mode). Freedom mode is
passive - it means "just give me the last known location, if the phone
has already reported one recently." The threshold for "recently" is
subject to change, but I believe it's currently 15 minutes. If the
last known location is older than that, then the request returns an
error - although it still returns the last known location too (as a
cached position), so you can decide for yourself whether it is too old
for your purposes. A Freedom mode request will never go through the
network to ask the phone for a new location (that's why it's free) -
so this will only be useful if the phone is able to report locations
to the server without being asked; smartphones can do this if they
have installed the Veriplace background application (currently
supported for BlackBerry and Android).

The phone in question is a BlackBerry, and you have installed the
Veriplace software, and it is reporting locations. However, to save
battery life and reduce network traffic, if it detects that the phone
has not moved, it will do less frequent location updates. I believe
you'll find that at the times when you got this error, the phone had
been stationary for a while, so it had not sent an update within 15
minutes of the time you made the request.

There are several ways you could choose to handle this. First, you
could check the cached position (assuming it can be parsed correctly -
see below) and if its creation timestamp is recent enough for your
purposes, just use that. If the position is an hour old, *and* if you
know that the user has a smartphone, then that means either that the
phone has not moved for an hour, or that it was turned off or lost
signal during that time. (If it's not a smartphone, then Freedom mode
isn't of much use anyway.)

Second, you could issue a Zoom or Area mode request. Those will go
through the network to ask the phone for a new location. Since those
modes do incur a charge, you might want to always try the Freedom mode
request first.


2. I am still not sure why you're seeing a null value from
PositionFailureException.getCachedLocation() when the response clearly
did include a cached position. If this is an SDK bug, I haven't been
able to reproduce it - and I've tried not only feeding the response
data you provided directly into the client code, but also making
Freedom mode requests to the same number you're using. In all cases,
the cached position was returned correctly.

Just to rule out the possibility that something in your application
logic is not doing what it's supposed to be doing - have you tried
running one of the example applications from the SDK, using your
application's credentials? Here's how to do it with the Swing-based
GUI demo:

- After building the SDK source, run "lib/swing-example.jar".
- Enter your consumer key/secret and application token/secret in the
text fields at the left.
- Enter the mobile number in the Find User section and click Fin.
- Click Get Location Permission.
- Click Get Location. If a valid location appears, close the location
window and click Get Location again (to force it to get an error,
since there won't be another new location yet).
- When you see a PositionFailureException message in red, click on
that message; an error detail window appears. Check whether there is
a "Cached Position" button (the button only appears if
getCachedLocation() returns non-null). If so, click it.

Please let me know if you're able to reproduce the problem with those
steps...


3. You asked whether Veriplace can get GPS locations as well as cell-
tower-based locations. Absolutely - in fact, the locations you have
been getting from that particular phone are all GPS data. We will
always return GPS data when it's available, unless the application has
specifically requested low accuracy by using Area mode. If the phone
can't get a GPS fix, then we fall back to a lower-accuracy mode -
basically cell-tower triangulation, though the exact implementation of
this depends on the carrier.

best,
Eli

Mishit

unread,
Sep 16, 2010, 11:39:51 AM9/16/10
to Location Labs Developer Community
Hello Eli
Thanks. Your detailed explanations make us more cognizant about
veriplace.

1) PositionFailureException
Even If I try with Zoom or Area mode its giving me the same
exception.
Is my veriplace account has any problem or its because my phone is
at indoor location and not getting GPS ( inside office building) ?
Even Google maps --> My Location is not giving me the exact location.
BTW do we get charged when we get such exception using zoom mode.
As every zoom mode request come through network and ask phone for new
location whether or not phone is locatable.

Also you mentioned that my BlackBerry has veriplace software
installed and its reporting locations(for freedom mode). But I haven't
installed any veriplace app like that.
It just I have registered my phone as developer phone for our
Veriplace application.

2) CachedLocation
Yeah. It worked from my IDE. I guess I shouldn't have any problem
reading CachedLocation now.

thanks
/Mishit

Eli Bishop

unread,
Sep 16, 2010, 8:31:37 PM9/16/10
to veriplace-deve...@googlegroups.com
Mishit,

See responses below -


On Thu, 2010-09-16 at 08:39 -0700, Mishit wrote:
> 1) PositionFailureException
> Even If I try with Zoom or Area mode its giving me the same
> exception.
> Is my veriplace account has any problem or its because my phone is
> at indoor location and not getting GPS ( inside office building) ?

I don't think the problem is your phone or the GPS signal. There was
something funny about the way the account for that device was
configured, and I'm trying to figure out how it got that way.
Basically, something did not get completely set up during registration
of that account so that it did not have the ability to send on-demand
location requests to the phone. It's not a problem with the carrier, it
is some odd condition in the Veriplace platform that I haven't seen
before. I'm looking into this - and it would be helpful to know, if you
remember, how you registered this device: that is, did you sign up via
web at veriplace.com from the device itself, or from a desktop browser,
or did you get an SMS invitation, etc.

In any case, I have made what I think is the necessary configuration
change - please try locating the device again with Zoom or Area mode and
let me know if it works now.


> BTW do we get charged when we get such exception using zoom mode.
> As every zoom mode request come through network and ask phone for new
> location whether or not phone is locatable.

No, we don't charge for unsuccessful requests.


> Also you mentioned that my BlackBerry has veriplace software
> installed and its reporting locations(for freedom mode). But I haven't
> installed any veriplace app like that.

Well, if we are talking about the same device (number ending in 378),
you definitely *do* have the Veriplace app on that phone. We are
receiving location data from it - I'm sure of it. That's the other
reason I ask whether you remember the signup/registration process you
went through - at some point there must have been a step where you were
given the option to click a link in your phone to download the app;
there's no other way it could have gotten on there.


> 2) CachedLocation
> Yeah. It worked from my IDE. I guess I shouldn't have any problem
> reading CachedLocation now.

I'm not entirely clear on this - do you mean that the example code
works, or that your own application code also works now but only if you
run it from the IDE?

best,
Eli

Mishit

unread,
Sep 24, 2010, 5:27:21 PM9/24/10
to Location Labs Developer Community
Hello Eli
Sorry couldn't reply you earlier. Anyways, here is an update.
1) PositionFailureException
After you corrected the account setting for this BB I am able to
get the location in zoom mode even in my office building.

Well, I registered this phone account from my desktop browser and I
guess then I got the email from veriplace.
First I registered for "Here I Am" and "The Lost Phone" app and two
days later I registered with our app as 'developer phone'.

2) CachedLocation
It worked with that swing application example and then with my code
too.
Yep. there was small mistake in my custom code.

Thank you so much Eli
Have nice weekend

/Mishit
Reply all
Reply to author
Forward
0 new messages