We have moved to a new Sailfish OS Forum. Please start new discussions there.
9

How to access geolocation from command line?

asked 2015-01-17 11:34:38 +0200

tobixen gravatar image

updated 2015-01-19 11:05:01 +0200

eric gravatar image

I'd like to get access to my position and gps data from the command line - surely that must be possible?

edit retag flag offensive close delete

4 Answers

Sort by » oldest newest most voted
6

answered 2015-01-17 18:30:31 +0200

kimmoli gravatar image

updated 2015-01-18 22:06:05 +0200

when maps is running, following command gives you lat,long

dbus-send --session --type=method_call --print-reply \
    --dest=org.freedesktop.Geoclue.Providers.Here \
    /org/freedesktop/Geoclue/Providers/Here \
    org.freedesktop.Geoclue.Position.GetPosition

something like

method return sender=:1.918 -> dest=:1.979 reply_serial=2
 int32 3
 int32 1421521856
 double 61.2342
 double 23.5406
 double nan
 struct {
    int32 5
    double 135.2
    double nan
 }

maybe there is way to enable it also from command line, but didn't yet figure it out.

(Couldn't find a way to send a{sv} aka QVariantMap from cli)

edit flag offensive delete publish link more

Comments

Any idea on how to do it w/o Here/Maps, i.e. just having the GPS enabled in Settings?

foss4ever ( 2015-01-18 05:43:19 +0200 )edit
1

Propably most efficient way would be to make a simple commandline tool for this purpose. Or maybe search internet for such written for Qt ?

kimmoli ( 2015-01-18 10:17:45 +0200 )edit
5

answered 2015-01-18 22:31:40 +0200

kimmoli gravatar image

Made small commandline app called position (also a learning project).

Altough i requested updates every second, it updates every 30 sec (?)

sources: https://github.com/kimmoli/position-cli

You can find readybuilt binary from mer obs (link valid for version 0.0.3)

http://repo.merproject.org/obs//home:/kimmoli/sailfish_latest_armv7hl/armv7hl/position-0.0.3-10.5.1.jolla.armv7hl.rpm

edit flag offensive delete publish link more

Comments

While developing GPSInfo I was also seeing this "problem" about the interval, it seems to be something like a minimum. While there is no GPS fix, you will get updates containing the last known location in a lower interval, but if the GPS is available you will get updates as soon as they are available.

balta ( 2015-01-19 09:46:58 +0200 )edit
1

Yep, also noticed the same thing when working on modRana. Until it gets a real GPS fix, it uses some alternative approximate method to get a preliminary fix every 30 seconds.

This alternative method is most probably WiFi an/or mobile cell positioning using a remote service over the Internet - you send it the WiFi AP MAC addresses/mobile cell ids and it tells you your approximate coordinates.

And the 30 second interval is mot probably rate limiting so that all the Jollas (and other devices) using the API don't DDoS it out of existence or there could be some usage quotas Jolla bought for the API, etc.

Also given the approximate nature of the coordinates returned (tens of meters in best case, which is still quite good actually), it won't make much sense to run another request sooner, unless you are currently moving.

MartinK ( 2015-01-19 14:10:37 +0200 )edit

thanks. So in Jolla there is no way to have GPS position unless maps app is open?

I am interested in writing an app to track when I go into or out of a specific geographic area and I need continuous GPS fix for it to work

c.la ( 2015-01-20 14:14:22 +0200 )edit

Is it possible to compile this on the Jolla?

Rolfa ( 2016-05-24 11:34:27 +0200 )edit
5

answered 2018-12-05 16:53:05 +0200

slowcyclist gravatar image

updated 2018-12-05 16:54:07 +0200

Late answer to the question, but I made a python script that actually starts the gps by itself and prints the gps coordinates. It does not need another application to be running, in contrast to the other answers.

You can get it from here

edit flag offensive delete publish link more
3

answered 2015-01-18 03:27:09 +0200

marsch gravatar image

Posted a howto some months ago which describes an approach based on cell location:

https://together.jolla.com/question/24943/howto-retrieve-gsm-cell-coordinates/

edit flag offensive delete publish link more

Comments

is there some terminal command which alternates enabling GPS from top menu? I have carmode script and want to use this command to enable GPS before starting map app

Malakay ( 2020-06-21 22:41:25 +0200 )edit
Login/Signup to Answer

Question tools

Follow
9 followers

Stats

Asked: 2015-01-17 11:34:38 +0200

Seen: 6,184 times

Last updated: Dec 05 '18