Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where am I? (Geolocation, Emacs, Perl) [closed]

This is one of those "surely there is some generic utility that is better than the quick and dirty thing I have whipped up" questions. As in, I know how to do this in several ad-hoc ways, but would love to use a standard.

BRIEF: I am looking for reasonably standard and ubiquitous tools to determine my present geographical location. Callable from Linux/UNIX command line, Perl, Emacs, etc.

DETAIL:

A trivial situation inspires this question (but there are undoubtedly more important applications): I use emacs org-mode, often to record a log or diary. I don't actually use the official org-mode diary much - mainly, I drop timestamps in an ordinary org-mode log, hidden in metadata that looks like a link.

[[metadata: timestamp="<2014-01-04 15:02:35 EST, Saturday, January 4, WW01>" <location location="??" timestamp="??"/>][03:02 PM]]

As you can see, I long ago added the ability to RECORD my location. But hitherto I have had to set it manually. I am lazy, and often neglect to set the location manually. (Minor note: I recorded the last time I manually set the location, helpful when I move and neglect to manually change my location.

I would much prefer to have code that automatically infers my location. Particularly since I have been travelling quite a bit in the last month, but probably more useful for the half-dozen or so locations I move between on a daily basis: home, work, oceanside, the standard restaurants I eat working lunch or breakfast in.

I can figure my location out using any of several tools, such as

  • Where Am I - See your Current Location on Google Maps - ctrlq.org/maps/where/

  • http://www.wolframalpha.com/input/?i=Where+am+I%3F

  • Perl CPAN packages such as IP::Location - to map an IP address to a location

    • note: doesn't necessarily work for a private IP address, behind NAT
    • but can combine with traceroute

and heuristics such as looking at WiFi SSIDs, etc.

I have already coded something up.

But... there's more depth to this than I have coded.

None of the techniques above is perfect - e.g. I may not have net.connectivity, etc. Some are OS specific.

If there is already some open source facility, I should use that.

Therefore my question: is there any reasonably ubiquitous geo location service?

My wishlist

  • Works cross OS

    • Cygwin
    • Linux
    • Android? OS-X? (just use OS standard)
    • e.g. tries to exec a command like Windows netsh, and if that fails...
  • Command line utility

    • Perl, etc.
    • callable in emacs
    • because that is where I want to use it
    • but I am sure that I would want to be able to use it in other places.
  • Can connect to widely available standard geolocation services

    • e.g. Perl CPAN IP::Location, IP->country/city/...
    • e.g. Google, etc., infer geographical location from browser
  • Works even when cannot connect to standard geolocation services, or the Internet

    • e.g. cache last location
    • e.g. ability to associate a name with a private network environment
    • e.g. if in a lab that is isolated from network
    • or at home, connected to WiFi, but broadband down
    • e.g. look at wifi SSID
  • Customizable

    • can use information that is NOT part of any ubiquitous geolocation database
    • e.g. I may recognize certain SSIDs as being my home or office.
  • Learned

    • Knows (or can learn) that some SSIDs are mobile, not geographically fixed (e.g. the mobile hotspot on my phone)
    • but some are (mainly) geographically fixed (e.g. WiFi at home connected to cable modem)
  • Learning

    • can override incorrect inferences (geo databases sometimes wrong, esp. VPN)
    • can extend or make precise
    • I wouldn't mind being able to write rules
    • but even better if some inference engine maintains the rules itself.
    • e.g. if I correct the location, make inferences about SSID coordinates used for the faulty inference
  • Heuristics

    • Windows 7 "netsh wlan show interfaces"
    • Windows / Cygwin ipconfig
    • *IX ifconfig
    • traceroute / tracert
    • reverse IP lookup
  • Caching

    • to avoid expensive lookups
    • but cache is NOT global - can be done per app
    • some apps may want to bypass the cache
    • others can use old data
like image 689
Krazy Glew Avatar asked Jan 04 '14 21:01

Krazy Glew


1 Answers

GeoClue seems to satisfy at least some of your requirements.

To convert coordinates to human-readable address, one can use OSM Nominatim API.

like image 173
AvImd Avatar answered Oct 04 '22 11:10

AvImd