19

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
zsltg
  • 725
  • 5
  • 14
  • 23
Krazy Glew
  • 7,210
  • 2
  • 49
  • 62
  • 5
    This question is as interesting as it is off topic: Tool recommendations don't belong on Stack Overflow. – amon Jan 04 '14 at 21:50
  • 6
    Please don't close it. It is a good question – justintime Jan 05 '14 at 04:23
  • 3
    Software tools used by programmers is an allowed topic. The guts of this would be very useful in many programs. I don't see why it does not belong here. – Bill Ruppert Jan 05 '14 at 15:56
  • 1
    There are 4,762 questions tagged geolocation, many of which are like http://stackoverflow.com/questions/1513485/how-do-i-get-the-current-gps-location-programmatically-in-android or http://stackoverflow.com/questions/5364914/where-to-start-location-awareness . My question differs mainly in that I am not asking "How do I know where I am on Android?" or any particular OS - I am looking for any pointers to cross platform APIs. Libraries that know how to invoke several other geolocation kits. – Krazy Glew Jan 06 '14 at 13:12

4 Answers4

2

GeoClue seems to satisfy at least some of your requirements.

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

AvImd
  • 75
  • 8
0

Why didn't you just consider using GPS ? You could just add coordinates to your metadata and bind them to an address (going from simple numbers to an actual place) upon reading.

In this way almost anything can be tagged with coordinates.

In gnu/linux and other unices, gpds should do.

In windows, I have no idea.

In Android, the scripting layer for android should provide access to the gps device.

I am not sure this meets your requirements, but I'm just proposing.

znpy
  • 474
  • 2
  • 10
  • Why not GPS? Because my question is generic: I want a package, an API, that I can use on my Android devices (one of which has GPS, but the older ones which do not), but also on the tablet PC that I am typing this at right now, which does not have GPS but which does have wifi, although is not always connected. And, come to think of it, when I am VNC'ed in to work - which may be interesting, involving backtracking and/or propagating information a to the location I am typing from. – Krazy Glew Jan 06 '14 at 13:07
  • The only thing that works the very same way on every device is direct access to GPS data coming from GPS device. – znpy Jan 06 '14 at 13:56
  • What I wanted to say (before discovering that pressing enter would post my comment instead going to a new line) is that the only way to get what you're asking is to develop that pagkage/API yourself. My suggestion is to make a generic library and expoit object-orientation and inheritance (for non-oop languages think of callback functions and abstract data types) in and develop platform-specific libraries compatible with your API. – znpy Jan 06 '14 at 13:59
  • Fair enough. I started writing such a package, although only the parts I need so far. Still, I am allowed to hope that it ha already been written, eh? – Krazy Glew Jan 07 '14 at 00:43
-1

Let me put it this way. You intend to track your location without using a positioning device such as gps. This is done based on your current geo location from your nearest network access point. The network access points are usually geo coded. I assume you are tracking your location in your laptop as it doesn't have a gps.

There must be a few frameworks out there to do this. Since you want it to be cross platform, I think a python based framework is your best option. You can also give google geo location a shot. There are a few api's built into html5 for geo location. I think you can coo-kup your own application and share it on opensource for everyone else to use.

For windows there are many commercial pc trackinga pps. All of them do a fine job at it.

preetam
  • 1,451
  • 1
  • 17
  • 43
-1

You could use wget to pull data from one of those sites you mentioned, something like wget http://www.wolframalpha.com/input/?i=Where+am+I%3F and then find the data out of the file you just downloaded