Commandline Tools for geocode?

I’d like to get my location from the command line to test what geocode2 or gnome location services believes my location to be. More or less I want to get to the bottom of why it it thinks I’m in a different time zone without taking guesses.

How can I do that?

If your distribution includes it you can run /usr/lib/geoclue-2.0/demos/where-am-i to get the latitude-longitude the location service determines for you. To convert that to, e.g., a city name you need to use Geocode but I don’t think there is a command for that.

I whipped up the below simple Python demo to use Geoclue and then Geocode to print the location the location service determines for you:

#!/usr/bin/python3
import gi
gi.require_version('Geoclue', '2.0')
gi.require_version('GeocodeGlib', '2.0')
from gi.repository import Geoclue, GeocodeGlib

clue = Geoclue.Simple.new_sync(
	'dummy',
	Geoclue.AccuracyLevel.NEIGHBORHOOD,
	None
)
clue_location = clue.get_location()

location = GeocodeGlib.Location.new(
	clue_location.get_property('latitude'),
	clue_location.get_property('longitude'),
	clue_location.get_property('accuracy')
)
reverse = GeocodeGlib.Reverse.new_for_location(location)
place = reverse.resolve()
print(
	place.get_country(),
	place.get_state(),
	place.get_county(),
	place.get_town()
)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.