Ask / Submit
8

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

3 Answers

Sort by » oldest newest most voted
7

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
6

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
4

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
Login/Signup to Answer

Question tools

Follow
8 followers

Stats

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

Seen: 1,653 times

Last updated: Jan 18 '15