Add BGeolocation experimental API.

Operating Systems / Haiku - Adrien Destugues [pulkomandy.tk] - 23 September 2014 09:37 UTC

A BGeolocation object can query an online service to get geolocation and geotagging data:
- LocateSelf() tries to locate the machine it is running on, by using an online database of wifi access points
- Locate() (not yet implemented) searches a BString and converts it to lat/lon coordinates (reverse geotagging)
- Name() (not yet implemented) finds a suitable name for the given coordinates (address, building name, or anything fitting).

The default service used is openbmap.org, which is freely available but not very accurate. A request has been sent to Mozilla to use MLS (Mozilla Location Services), which is a bit more accurate but needs an API key. MLS is used for geolocation on FirefoxOS, for mobile phones which don't have a GPS, and the data can be contributed by Firefox for Android or the dedicated MozStumbler app.

Alternatively, Google Maps also provide the service, but wants people to pay for it. Google Maps data is more accurate as all Android devices contribute data to it.

All 3 services use the same JSON-based API: we send a list of reachable Wifi APs (mac address and signal strength), and we get lattitude and longitude information, and possibly extra data which will currently be unused.

This can be used to implement HTML5 geolocation with reasonably accurate results, but it can also be used in other places. For example FirstBootPrompt could try to guess a list of most likely languages and keyboard layouts from it (if wifi is working at install time, that is).

13f0458 Add BGeolocation experimental API.
headers/private/shared/Geolocation.h | 29 ++++
src/kits/network/libnetapi/Geolocation.cpp | 139 ++++++++++++++++++++
src/kits/network/libnetapi/Jamfile | 14 +-
src/tests/kits/net/service/GeolocationTest.cpp | 41 ++++++
src/tests/kits/net/service/GeolocationTest.h | 23 ++++
src/tests/kits/net/service/Jamfile | 3 +
src/tests/kits/net/service/ServiceKitTestAddon.cpp | 2 +
7 files changed, 245 insertions(+), 6 deletions(-)

Upstream: cgit.haiku-os.org


  • Share