Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 49
Registered: ‎11-11-2012
My Device: z10 LE
My Carrier: Digi

toggle QGeoPositionInfoSource

Hi,

 

am trying to make location service in app more accurate to user. Is it possible to toggle the QGeoPositionInfoSource::AllPositioningMethods to use QGeoPositionInfoSource:Smiley FrustratedatellitePositioningMethods at run time programmatically based on positionUpdated information?

 

 

I've tried solely QGeoPositionInfoSource::AllPositioningMethods but it's giving me results from both Wifi/Cell and GPS thus a zig zag/flux. Doesn't seemed to be falling to GPS only when it's available, still reporting non-gps results in addition to GPS.

 

thanks,
James Tan



James Tan
Eating my dog food - TripLogger, my 1st bb10 app.
Developer
Posts: 133
Registered: ‎05-10-2013
My Device: Blackberry Z10
My Carrier: -

Re: toggle QGeoPositionInfoSource

[ Edited ]

You can use a specified positionning method with the SetPreferedPositioningMethod method.

 

GPS

 

You can restrict your app to only retrieve the GPS location of a device. To only use GPS positioning methods, set the provider property to gnss and the fixType property to gps_autonomous.

 

src.setProperty("provider", "gnss");

src->setProperty("fixType", "gps_autonomous");

 
----------------------------------------
Remember to mark the thread as solved at the post that solved your problem, and if you like a post, like it!
Retired
Posts: 68
Registered: ‎10-15-2012
My Device: Z10
My Carrier: Telus

Re: toggle QGeoPositionInfoSource

If you're getting periodic updates remember to stop and restart updates when changing parameter values:

 

src->stopUpdates();

src->setProperty("provider", "gnss");

src->setProperty("fixType", "gps_autonomous");

src->startUpdates();

 

James, this flip flop behaviour between network and gps updates using AllPositioningMethods was present in older builds but should be fixed. Are you using a recent build on your device? If so, can you provide more information on how you make this happen? Sample code, capture the QGeoPositionInfo data as it is flip-flopping?

 

Thanks,

Jim

Highlighted
Developer
Posts: 49
Registered: ‎11-11-2012
My Device: z10 LE
My Carrier: Digi

Re: toggle QGeoPositionInfoSource

Thanks for the tips to diagnose, am using the 10.1.0.273 z10 (LE).

 

Before I copy and paste my code, can I ask if it's possible to derive the source when AllPositioningMethods returns a pos, so that I can debug if that pos belongs to Sat or to Wifi or others.

 

thanks!



James Tan
Eating my dog food - TripLogger, my 1st bb10 app.
Retired
Posts: 68
Registered: ‎10-15-2012
My Device: Z10
My Carrier: Telus

Re: toggle QGeoPositionInfoSource

You can get a good idea of the source by looking at the horizontal accuracy (an attribute of QGeoPositionInfo). Wifi typically reports 60m, cellsite > 3000m, gps < 50m. You can know for certain by parsing the replyDat property of QGeoPositionInfoSource - you must  access this property from within your slot connected to the positionUpdated() signal. See http://developer.blackberry.com/cascades/reference/qtmobilitysubset__qgeopositioninfosource.html, search for replyDat. Note that replyDat represents raw data output by the underlying BB Location Manager. replyDat is a QVariantMap, so you may have to dig a bit to get the info you want. 

 

You can pull out the fix type with code like this:

 

QString fixType;
QVariant variant = posInfoSource->property("replyDat");
if ( variant.isValid() ) {
    // the replyDat property is a QVariantMap
    QVariantMap rawDat = variant.toMap();
    QVariant field = rawDat.value( "fix_type" );
    if ( field.isValid() ) {
        fixType = field.toString();
    }
}

 (Use with care, I haven't actually tested this code (modified from http://developer.blackberry.com/cascades/reference/qtmobilitysubset__qgeopositioninfosource.html, which has been tested)

 

Also note that the contents of replyDat are informational, but there is no guarantee that a given field will always be present.